Skip to content

Instantly share code, notes, and snippets.

@robotlolita
Created September 26, 2010 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robotlolita/598386 to your computer and use it in GitHub Desktop.
Save robotlolita/598386 to your computer and use it in GitHub Desktop.
(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