I have a code snippet down below.
var obj = {
name: "Mohit",
func: function(){
var self = this;
(function(){
console.log(this.name);
console.log(self.name)
})()
}
}
After executing obj.func(), I get the first console.log to be undefined while I get the second one to be Mohit.
Does this mean that an IIFE always binds the this to the global window object?
How defining self to be this is the binding for the IIFE happening to the obj?