-2

I was trying to acquaint myself with some advanced javascript and have been reading some of the jquery code on github when, I came across a anonymous function wrapped in parenthesis here.

Now, I am already aware of the concept of IIFE and the plethora of questions on SO regarding the subject, for instance - IIFE question here. But, this is not an IIFE, at least, is not invoked immediately IMHO.

I'm trying to figure out the use of such code and how it fits into the larger scheme of things. Since, the function is anonymous, I'm wondering how it is called or referenced.

Community
  • 1
  • 1
Neil DCruz
  • 195
  • 2
  • 13

1 Answers1

2

It is an IIFE -- it just gets called with a very long argument.

( function( global, factory ) {

    "use strict";

    // .....

// Pass this if window is not defined yet
} )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
     // ...
    return jQuery;
} );

A function is passed as an argument, which gets used in the upper function. But it clearly is a standard IIFE otherwise.

Scimonster
  • 32,893
  • 9
  • 77
  • 89