for (let j=0; j<3; j = j+1) {
    setTimeout(function() {
      console.log(j);
    }, 1000);
}
output 0 1 2
for (var j=0; j<3; j = j+1) {
     setTimeout(function() {
         console.log(j);
     }, 1000);
}
output 3 3 3
I understand why using var prints 3 always. But even let also should print all 3. Explain?
 
     
    