function Mistake(x); self = this; x.on("event", function() { console.log(self); }); } new Mistake(…);
Did you notice this? Now we have a global self , which is not self , that the reference expects. Therefore, it checks whether self is really a global object, which is likely to happen when self is an object, and the object has a "global variable" self as a property that points to the object itself.
The same goes for global .
Bergi source share