I was looking at the code in angular 1.3.4 for angular.forEach and it looks like the following...
function forEach(obj, iterator, context) {
...
for (key = 0, length = obj.length; key < length; key++) {
if (isPrimitive || key in obj) {
iterator.call(context, obj[key], key, obj);
}
...
return obj;
}
But according to this link, it is faster to use decrement. So should I switch over to a pure javascript for loop? Why does the Angular team increment if performance is an issue? or is there a way (short of rewriting) to get angular.forEach to do this?
$.eachetc) would expect it to iterate through something in the usual order, ie first item first. Doing otherwise would be rather unexpected. If performance is your main concern, don't go using library based utility functions that are probably doing a bunch of other things you don't need also.