Skip to content

Instantly share code, notes, and snippets.

@dylansmith
Created August 31, 2018 15:58
Show Gist options
  • Save dylansmith/48af726d65a90a94ee5cf1e0cc5afa36 to your computer and use it in GitHub Desktop.
Save dylansmith/48af726d65a90a94ee5cf1e0cc5afa36 to your computer and use it in GitHub Desktop.
number-to-string-wtf.js
console.time('Number.toString');
for (var i=0; i < 1000000; i++) {
Number.toString(i);
}
console.timeEnd('Number.toString');
console.time('i.toString');
for (var i=0; i < 1000000; i++) {
i.toString();
}
console.timeEnd('i.toString');
console.time('template string');
for (var i=0; i < 1000000; i++) {
`${i}`;
}
console.timeEnd('template string');
console.time('string concat');
for (var i=0; i < 1000000; i++) {
''+i;
}
console.timeEnd('string concat');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment