In a browser (not in generic javascript), self
is a property of the window
object that contains the value of the current window
. Since all properties of the window
object are accessible as global variables, you can refer to just self
and it will contain a reference to the current document's window.
Thus, in your code:
var global=ElizaBot.prototype.global=self;
is assigning to both ElizaBot.prototype.global
and to the variable global
a reference to the current window
object.
See here for info on window.self
which is also accessible as just self
.
FYI, all of these assignments seem superfluous since the current window object is generally accessible in other ways and need not be stored separately.