Skip to content

Instantly share code, notes, and snippets.

@erhangundogan
Created November 29, 2013 22:17
Show Gist options
  • Select an option

  • Save erhangundogan/7712713 to your computer and use it in GitHub Desktop.

Select an option

Save erhangundogan/7712713 to your computer and use it in GitHub Desktop.
var a = [1,2,3,4,5,6,7,8,9,10];
console.time('testing_forward');
for (var i = 0; i < a.length; i++);
console.timeEnd('testing_forward');
// output: testing_forward: 0.041ms
console.time('testing_backwards');
for (var i = a.length - 1; i >= 0; i--);
console.timeEnd('testing_backwards');
// output: testing_backwards: 0.030ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment