Context of this doesn't work as expected. I have described my issue in as comments in the code below.
const dog = {
//arrow function
bark: () => {
console.log(this);
},
makeBark(){
// this here refers to the dog object
// (as it is a normal function)
// so inside the bark function , shouldn't
// this refer to the dog object ?
this.bark();
},
};
dog.makeBark(); // this is the problematic function
I dont understand WHY dog.makeBark()
prints window object . The parent scope of bark function is the dog object