0

I see jQuery is wrapped with...

(function( window, undefined ) {
   ...
})(window);

Source.

I see it passes in window again (my guess to make accessing it faster), but why is undefined there, and it is not passed in the self invoking function?

My guess is to protect jQuery from some bozo doing...

var undefined = 'defined';

In that instance, undefined will be the string 'defined', and that is bad.

If I'm right (always a first :P), then it is a clever way of ensuring that undefined is always really undefined.

Am I right? Can anyone elaborate? Does passing window again indeed make things faster?

Thanks.

alex
  • 479,566
  • 201
  • 878
  • 984

0 Answers0