0

Why this behaves differently behave in the case of let and var

function foo() {
  console.log(this.a);
  console.log(this.b);  // why it gives undefined
}


let b = 99;
var a = 66;

foo();
gANDALF
  • 250
  • 2
  • 12
  • "let" has a limited scope. "Scope" is a technical term which in short explains where a declared variable is usable and where it's not, I would advise you to look it up – Victor bvn Jun 08 '21 at 15:12

0 Answers0