Reputation: 27114
array_of_strings = ["this", "is", "my", "array", "of", "strings"]
array_of_strings.each(function(val, i) { console.log(i) })
Which returns :
TypeError: Object has no method 'each'
I thought I could iterate through an array this way..
Upvotes: 2
Views: 48
Reputation: 79830
What you have is for iterating jQuery objects. You should use $.each
like below,
// index----v v-----value
$.each(array_of_strings, function(i, val) { console.log(val) });
Also the params inside $.each
function is (index,value)
Upvotes: 5