首页 > 解决方案 > 没有最后括号的闭包是什么?

问题描述

闭包和 what-c​​ha-ma-call-it 有什么区别?

我明白那个

var x = (function(){})();  

x 得到一个闭包。这里没什么特别的。

var y = (function(arg1){
            const _hello = ()=>{ return' world'}
           return {
                 hello:_hello
             }
       });

y是什么?什么叫它?

var x = y(arg)

x 现在是什么?还是闭包?

标签: javascript

解决方案


(function(){})()将执行该功能,尝试(function(){console.log(0)})()

并尝试(function(item){console.log(item)})(0)

y 将是一个函数。

x = {"hello": ()=>{ return' world'}}


推荐阅读