Invoking a function as an anonymous function, this
will be the global object (self
in the browser).
function func() {
return this;
}
func() === window; // true
In ECMAScript 5's strict mode, this
will be undefined
if the function is invoked anonymously.
(function () {
"use strict";
func();
}())
This will output
undefined