Skip to content

Instantly share code, notes, and snippets.

@GiuseppeMP
Last active June 21, 2021 17:17
Show Gist options
  • Save GiuseppeMP/b9278dc377140599060a82d00449efb7 to your computer and use it in GitHub Desktop.
Save GiuseppeMP/b9278dc377140599060a82d00449efb7 to your computer and use it in GitHub Desktop.
The computing price of escapping characters in strings that not needed.
function testingDoubleQuotes(){
console.time('doublequotes')
for (let i = 0; i < 10000000; i++) {
const string1 = "String One"
}
console.timeEnd('doublequotes')
}
function testingSingleQuotes(){
console.time('singlequotes')
for (let i = 0; i < 10000000; i++) {
const string2 = 'String Two'
}
console.timeEnd('singlequotes')
}
function testingbackticks(){
console.time('backticks')
for (let i = 0; i < 10000000; i++) {
const string1 = `String Three`
}
console.timeEnd('backticks')
}
testingDoubleQuotes()
testingSingleQuotes()
testingbackticks()
/**
* doublequotes: 1.936ms
* singlequotes: 0.933ms
* backticks: 0.924ms
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment