javascript - 没有最后括号的闭包是什么?
问题描述
闭包和 what-cha-ma-call-it 有什么区别?
我明白那个
var x = (function(){})();
x 得到一个闭包。这里没什么特别的。
var y = (function(arg1){
const _hello = ()=>{ return' world'}
return {
hello:_hello
}
});
y是什么?什么叫它?
var x = y(arg)
x 现在是什么?还是闭包?
解决方案
(function(){})()
将执行该功能,尝试(function(){console.log(0)})()
并尝试(function(item){console.log(item)})(0)
y 将是一个函数。
x = {"hello": ()=>{ return' world'}}
推荐阅读
- javascript - 检查对象是否存在于数组中,不包括特定属性
- python - python3使用指定的打印机打印横向图像/文件
- java - Flink-SQL 窗口表连接?
- unity3d - 如何防止 GameObject 检测到未引用的碰撞
- azure - 执行 VBS 文件的 Azure Batch Task 问题
- javascript - Vuejs如何取回原始数组值
- android-studio - 如何向我的应用程序添加 100 多张图片
- python - SQLAlchemy 关系:一个字段,多个外键
- jquery - RequiredFieldValidator 有时不起作用,但无法重现它
- python - Python 内置 AsyncIO 实现?