Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
array_of_strings = ["this", "is", "my", "array", "of", "strings"] array_of_strings.each(function(val, i) { console.log(i) })
哪个返回:
TypeError: Object has no method 'each'
我以为我可以以这种方式遍历数组..
What you have is for iterating jQuery objects. You should use $.each like below,
$.each
// index----v v-----value $.each(array_of_strings, function(i, val) { console.log(val) });
Also the params inside $.each function is (index,value)
(index,value)