Created
February 15, 2017 13:46
-
-
Save b3rew/9c5eb20569ceb68c42622fdaaf9eafd2 to your computer and use it in GitHub Desktop.
var vs let
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
var sum = 0; | |
var length = 1000000000; | |
var i = 0; | |
// let j = 0; | |
console.time("let time"); | |
for(let j = 0;j<length;j++){ | |
sum += j; | |
} | |
console.timeEnd("let time"); | |
console.info("let total ", sum) | |
console.log("-------------------------------") | |
sum = 0; | |
console.time("var time"); | |
for(i = 0;i<length;i++){ | |
sum += i; | |
} | |
console.timeEnd("var time"); | |
console.info("var total ", sum) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment