1

Please explain how does this syntax actually works in javascript. I know that it somehow define mod, but I have never seen (function(){...})(function(){...}) syntax in javascript before.

(function(mod) {
  if (typeof exports == "object" && typeof module == "object") // CommonJS
    module.exports = mod();
  else if (typeof define == "function" && define.amd) // AMD
    return define([], mod);
  else // Plain browser env
    this.Mod = mod();
})(function() { ... } );
user1542639
  • 597
  • 6
  • 21

0 Answers0