Using this, jQuery defines a global variable with the real undefined
value. having a global variable like myvar
means you have this variable in your window
scope (like window.mywar
), if you run this code in the window scope:
var myvar = "whatever";
javascript defines your variable as if you have run this:
window.myvar = "whatever";
Let's assume we don't have a global variable like myundefined
which means window.myundefined
does not exist and window.myundefined
has no value, it means window.myundefined
is really undefined
, then you can create a global variable named undefined
in your window scope like this:
window.undefined = window.myundefined
and this line has the exact same result as the jQuery code that you have mentioned above. In other words jQuery could have done the same with this code:
window.undefined = window.myundefined
or
window.undefined = window.whatever_you_want_with_no_value
these both define a global variable with no value.