In below example, why the var takes long time than let in for loop ? I did some research on this and found that the var define variable globally because of functional scope and let define variable in block scope. that's why 'var' takes long time than 'let' but still not able to find the practically understanding about why it is so ?
console.time('letCounter');
for (let letCounter = 0; letCounter < 10500; letCounter++) {
console.log('letCounter', letCounter);
}
console.timeEnd('letCounter');
// 598.838134765625ms
console.time('varCounter');
for (var varCounter = 0; varCounter < 10500; varCounter++) {
console.log('varCounter', varCounter);
}
console.timeEnd('varCounter');
// 656.56494140625ms