javascript - (function(){})() 与 !function(){}()

标签 javascript design-patterns plugins

<分区>

在我看到的 jQuery javascript 代码中

(function(window, undefined) {
})(window);

在推特上

!function(window, undefined) {
}(window);

谁能说出这两种方法之间的区别是什么?

最佳答案

使用!函数之前的运算符使它被视为表达式,因此我们可以调用它:

!function() {}()

http://jasonlau.biz/home/faq/what-is-the-exclamation-mark-used-for-in-code

关于javascript - (function(){})() 与 !function(){}(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16340063/

相关文章:

javascript - Material-UI 的 Dialog 如何允许对话框后面进行交互?

javascript - 如何对功能测试函数进行单元测试

jQuery计算插件: show total in form field rather than text

c# - 将复杂数据类型从纯 c 插件传递到 Unity C# 脚本

javascript - On Height CSS 响应性

c# - 寻找设计模式来自动执行重复任务,例如登录/注销

java - 是否可以通过 "hash"数字比较两个字符串?

c++ - 在硬件接口(interface)之间切换的最佳设计模式

internet-explorer - Internet Explorer多个jdk版本

javascript - 在 FullCalendar 中添加额外的自定义资源表