In JavaScript I am aware of a number of different ways to iterate over each element in an array. At present my favorite is the array.forEach(function(entry){})
style but I know there is also the traditional for (var i = 0; i < array.length; i++)
as well as for (entry in array)
and JQuery's $.each()
method.
My question is this:
given a list of variable length eg: var arr = ['abc', 'xyz', '123', ...]
what's the best way to loop over each element?