Skip to content

Instantly share code, notes, and snippets.

@katsuma
Created October 21, 2012 16:46
Show Gist options
  • Save katsuma/3927553 to your computer and use it in GitHub Desktop.
Save katsuma/3927553 to your computer and use it in GitHub Desktop.
var max = 10000
var pi = Math.PI;
var a = new Array(max);
console.time('native');
for (var i = 0, len = a.length; i < len; i++) {
a[i] = pi;
};
console.timeEnd('native');
var b = new Array(max);
console.time('each');
$.each(b, function(k, v) {
b[k] = pi;
});
console.timeEnd('each');
// Use http://code.jquery.com/jquery-1.8.2.min.js
// native: 58ms
// each: 40ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment