We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
No description provided.
The text was updated successfully, but these errors were encountered:
在js中,需要初始化某些问题,但是后续操作有不需要用作此函数,为了节省内存空间,出现了立即执行函数。立即执行函数有一下几个特点:
执行后立即被销毁
大多是匿名函数
用来初始化的函数
常用于解决闭包
立即执行函数有俩种形式
(function (){}()) (function (){})()
常使用第一种(W3C规定)
另外,只有表达式才能被执行函数执行,所以
function test(){ }();
这个是不能被执行的,因为他只是声明了函数,不是表达式
能被执行符号执行的函数,函数名就基本忽略,所以立即执行函数为匿名函数,执行后立即被销毁,js中再无此函数。对于上述俩种格式,第二种括号包住,很明显是表达式,而第一种在里面包括,首先执行外面的括号,所以里面的内容也就是表达式,函数可以被执行符号执行。
Sorry, something went wrong.
No branches or pull requests
No description provided.
The text was updated successfully, but these errors were encountered: