Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Created Sep 26, 2010
Embed
What would you like to do?
(function() {
var stuff = "str";
// creates a really long string
var str = "";
for (var i = 0; i < 10000; ++i) {
str += 'stuff + ';
}
eval("stuff = 'str'; var d = +new Date; x = " + str
+ " stuff; console.log('Concat: ' "
+"+ (+new Date - d));");
// creates a really long array
var arr = [];
var d = +new Date;
for (var i = 0; i <= 10000; ++i) {
arr[i] = stuff;
}
arr.join("");
console.log('Join: ' + (+new Date - d));
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment