JQuery.each () does not iterate over an array of strings as expected

Doing:

var tags = ["foobar", "hello", "world"]; $.each(tags, function(tag) { console.log(tag); }); 

Gives me a conclusion

 0 1 2 

Why is my conclusion not

 foobar hello world 

Jsfiddle

+7
source share
1 answer

Do this, the first parameter for the index:

 $.each(tags, function(index, tag) { console.log(tag); }); 
+12
source

All Articles