2

the question is best explained with code:

let c = 1;
let d = 2;
function show() {
console.log(this.c, this.d);
}
// show() returns "undefined undefined"

var a = 1;
var b = 2;
function display() {
console.log(this.a, this.b);
}
// display() returns "1 2"

why is this?

Jianyuan Chen
  • 53
  • 2
  • 9

0 Answers0