Created
November 10, 2016 17:59
-
-
Save willgm/cd1eddae37a85195e4d7eb3f061c15f8 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
[1, 10, 100, 10000, 1000000, 100000000, 1000000000] | |
.forEach(size => { | |
console.log('with', size) | |
console.time('var'); | |
for (var i = 0; i < size; i++) {} | |
console.timeEnd('var') | |
console.time('let'); | |
for (let i = 0; i < size; i++) {} | |
console.timeEnd('let') | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Result with node v7.0.0:
$ node var-let-loop.js
with 1
var: 0.082ms
let: 0.014ms
with 10
var: 0.013ms
let: 0.002ms
with 100
var: 0.002ms
let: 0.002ms
with 10000
var: 0.028ms
let: 0.574ms
with 1000000
var: 0.599ms
let: 2.280ms
with 100000000
var: 57.668ms
let: 205.675ms
with 1000000000
var: 557.546ms
let: 2039.702ms