what is self-executing anonymous function or what is this code doing?

前端 未结 4 1017
生来不讨喜
生来不讨喜 2020-12-24 09:43
var module = {};


(function(exports){

  exports.notGlobalFunction = function() {
    console.log(\'I am not global\');
  };  

}(module));

function notGlobalFunct         


        
4条回答
  •  甜味超标
    2020-12-24 10:33

    The IIFE is adding a method to the module object that is being passed in as a parameter. The code is demonstrating that functions create scope. Methods with the same name are being added to a object and the the head object (window) of the browser.

提交回复
热议问题