Skip to content

Instantly share code, notes, and snippets.

@mraleph
Created September 25, 2012 10:39
Show Gist options
  • Select an option

  • Save mraleph/3781116 to your computer and use it in GitHub Desktop.

Select an option

Save mraleph/3781116 to your computer and use it in GitHub Desktop.
var a = "a";
var b = [];
for (var i = 0; i < 10; i++) {
a += a;
b.push(a);
}
b = b.join('');
// here a is a dag of cons-strings (rope), b is a flat string (like a normal char[])
a.charCodeAt(123); // here a gets flattened into a flat string.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment