Execution Context
Execution Context
const obj = {
p1: 10,
getP1() {
// In this case, if a normal function declaration was used, it would steel the 'this' reference
// So since arrow functions dont inject the 'this'....'this' keeps referencing 'obj'
const fn1 = () => {
return this.p1;
}
return fn1();
}
}
console.log(obj.getP1());Last updated