Created
August 31, 2018 15:58
-
-
Save dylansmith/48af726d65a90a94ee5cf1e0cc5afa36 to your computer and use it in GitHub Desktop.
number-to-string-wtf.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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