The result is 10
when I use var
keyword:
var x = 10;
let foo = {
x: 90,
getX: () => {
return this.x
}
}
console.log(foo.getX())
But undefined
is the result when I use let keyword:
let x = 10;
let foo = {
x: 90,
getX: () => {
return this.x
}
}
console.log(foo.getX())
I cannot understand why there are two different results, when both of them have the same global scope.