JavaScript scope and closure

前端 未结 7 1930
执笔经年
执笔经年 2020-11-28 09:21

I\'m trying to wrap my head around closures (there\'s a joke in there somewhere) and I ran across this:

(function () { /* do cool stuff */ })();
7条回答
  •  抹茶落季
    2020-11-28 10:15

    i just came across this post recently. This type of function definition & call is called self-invoking functions.

    (function(){  //code })();
    

    The code inside the function will be executed immediately upon its definition.

提交回复
热议问题