Created
May 28, 2017 14:20
-
-
Save lukechilds/538dde312de924a3854121193ea6c7c9 to your computer and use it in GitHub Desktop.
This file contains 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
const iterations = 100000000; | |
(() => { | |
console.time('Var While'); | |
var iVarWhile = 0; | |
while (iVarWhile < iterations) { | |
iVarWhile += 2; | |
} | |
console.timeEnd('Var While'); | |
})(); | |
(() => { | |
console.time('Let While'); | |
let iLetWhile = 0; | |
while (iLetWhile < iterations) { | |
iLetWhile += 2; | |
} | |
console.timeEnd('Let While'); | |
})(); | |
(() => { | |
console.time('Var For'); | |
var iVarFor = 0; | |
for (iVarFor = 0; iVarFor < iterations; iVarFor += 2) {} | |
console.timeEnd('Var For'); | |
})(); | |
(() => { | |
console.time('Let For'); | |
let iLetFor = 0; | |
for (iLetFor = 0; iLetFor < iterations; iLetFor += 2) {} | |
console.timeEnd('Let For'); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment