Hacker News new | ask | show | jobs
by svnv 5804 days ago
Isn't this faster for iterating over the elements:

  var a = ["banana", Math.min, 4, "apple"];
  for (var i=a.length; i; i--) {
    console.log(a[i]);
  }
4 comments

Actually, I just realized this does not work, there is an off by 1 error here. jacksoncarter's piece of code works though.
Or try this

  var i = a.length;
  while (i--){
    console.log(a[i]);
  }
Clever, but sometimes you don't want to go in reverse.
Yes, in a micro-optimized way.