const obj = {
a: "prakash",
name: function() {
console.log(this.a);
}
}
// Returns undefined because we extract
// it from obj and this is points to window object.
setTimeout(obj.name, 500);
// returns Prakash
setTimeout(function() {
obj.name();
}, 500);
Could you please explain me how it is working inside the anonymous function. I know I can use "bind", instead of anonymous function. But I wanna know, the reason why it works when you use anonymous function.