Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IIFE (Imdiately Invoked Function Expression 立即执行的函数表达式) #56

Open
5Mi opened this issue Aug 9, 2016 · 0 comments

Comments

@5Mi
Copy link
Owner

5Mi commented Aug 9, 2016

通过一元操作符+变成了函数表达式。也可以使用 - ~ !等其他一元运算符或者括号,目的是为了引导解析器,指明运算符附近是一个表达式。以下是三种经典方式 :

+function () {   

};  

(function () {  

});  

void function() {  

};  

函数表达式通过 末尾的() 来调用并运行。就是一个IIFE。

运算符:+加-减!逻辑非~位取反,返回NaN(Not A Number)。

“()”组运算符:返回表达式的执行结果undefined。

void:按运算符结合语句执行,返回 undefined。

来自

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant