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
在 IIFE 中所建立的变量,都不会影响到全局执行上下文所建立的变量。也就是说放在 IIFE 里面的变量,并不会影响到其他外层的变量,也不会被外层的变量影响。
一道经典的面试题就需要IIFE解决。 按照顺序每隔一秒打印数组的元素。
var arr = [1,2,3,4,5] for(var i=0; i<arr.length; i++){ (function(index){ setTimeout(function(){ console.log(arr[index]) },1000) })(i) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在 IIFE 中所建立的变量,都不会影响到全局执行上下文所建立的变量。也就是说放在 IIFE 里面的变量,并不会影响到其他外层的变量,也不会被外层的变量影响。
一道经典的面试题就需要IIFE解决。
按照顺序每隔一秒打印数组的元素。
The text was updated successfully, but these errors were encountered: