0

I saw a function in a file, Something like this..

! function(e) {
    if ("object" == typeof exports && "undefined" != typeof module) module.exports = e();
    else if ("function" == typeof define && define.amd) define([], e);
    else {
       var f;
       "undefined" != typeof window ? f = window : "undefined" != typeof global ? f = global : "undefined" != typeof self && (f = self), f.kwsUtils = e()
       alert('Inside the function....e is '+e);
    }
}

When I try the same thing in my NodeJS file, the function is not called, Do tell if you have any idea what these functions are called and how are they called.

Evan Davis
  • 35,493
  • 6
  • 50
  • 57
Hardeep Mehta
  • 469
  • 1
  • 6
  • 17
  • 2
    Put `()` after the last `}` and you will call this function. – VisioN Aug 30 '14 at 16:57
  • That should be an `IIFE` just `()` so it will be immediately invoked. – Mritunjay Aug 30 '14 at 16:59
  • I need to invoke it explicitly, and not by just calling it immediately, The file on which I am working does it some how..I don't know how but I am going to find out. – Hardeep Mehta Aug 30 '14 at 16:59
  • @Mathletics `!` is used to save another byte in `(function(){})()` and nothing else (well, maybe also to confuse people). Function is invoked with parentheses in both cases. – VisioN Aug 30 '14 at 17:02
  • @VisioN oops, posting while tired. Of course I meant in conjunction with the trailing parens; one without the either is either a no-op or an error, respectively. – Evan Davis Aug 31 '14 at 22:30

0 Answers0