Skip to content

Instantly share code, notes, and snippets.

@b3rew
Created February 15, 2017 13:46
Show Gist options
  • Save b3rew/9c5eb20569ceb68c42622fdaaf9eafd2 to your computer and use it in GitHub Desktop.
Save b3rew/9c5eb20569ceb68c42622fdaaf9eafd2 to your computer and use it in GitHub Desktop.
var vs let
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