Skip to content

Instantly share code, notes, and snippets.

@kurtisdunn
Last active August 29, 2015 14:19
Show Gist options
  • Save kurtisdunn/66095486f7429d04291f to your computer and use it in GitHub Desktop.
Save kurtisdunn/66095486f7429d04291f to your computer and use it in GitHub Desktop.
JavaScript for loop times. Native, jQuery, underscorejs.
//native: 0.066ms
console.time('native');
var l = array.length;
for (var i=0;i<l; i++) {
array[i] = i;
}
console.timeEnd('native');
//jquery: 1.259ms
console.time('jquery');
$.each (array, function (i) {
array[i] = i;
});
console.timeEnd('jquery');
//underscorejs: 0.423ms
console.time('underscorejs');
_.each (array, function (i) {
array[i] = i;
});
console.timeEnd('underscorejs');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment