Skip to content

Instantly share code, notes, and snippets.

@ajcrites
Created June 16, 2014 19:13
Show Gist options
  • Save ajcrites/61c7924c0ceb54b47580 to your computer and use it in GitHub Desktop.
Save ajcrites/61c7924c0ceb54b47580 to your computer and use it in GitHub Desktop.
var arr = new Array(100000);
for (var x = 0; x < arr.length; x++) {
arr[x] = 1;
}
console.time("for");
for (var x = 0; x < arr.length; x++) {
console.error(arr[x]);
}
console.timeEnd("for");
console.time("forEach");
arr.forEach(function (x) {
console.error(x);
});
console.timeEnd("forEach");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment