Created
September 16, 2016 03:45
-
-
Save pvamshi/98f4a488009c66d2c8fa0b70274dc789 to your computer and use it in GitHub Desktop.
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
(()=>{ | |
let name = 'hello'; | |
let name2 = `hello`; | |
let x = 0; | |
console.time('single quote: equals'); | |
for (let i = 0; i < 100000000; i++) { | |
if (name === 'hello') { | |
x++; | |
} | |
} | |
console.timeEnd('single quote: equals'); | |
x = 0; | |
console.time('backtick: equals'); | |
for (let i = 0; i < 100000000; i++) { | |
if (name2 === `hello`) { | |
x++; | |
} | |
} | |
console.timeEnd('backtick: equals'); | |
} | |
)(); | |
(()=>{ | |
let name = 'hello'; | |
let name2 = `hello`; | |
let x = 0; | |
console.time('single quote: concat'); | |
for (let i = 0; i < 1000000; i++) { | |
name = 'hello' | |
name += ' world' | |
if (name === 'hello world') { | |
x++; | |
} | |
} | |
console.timeEnd('single quote: concat'); | |
x = 0; | |
console.time('backtick: concat'); | |
for (let i = 0; i < 1000000; i++) { | |
name2 = `hello`; | |
name2 += ` world`; | |
if (name2 === `hello world`) { | |
x++; | |
} | |
} | |
console.timeEnd('backtick: concat'); | |
} | |
)(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment