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
for(var i=0; i<10; i++){ setTimeout(function(){ console.log(i) // 连续打印 10 个 10 },200) }
将 var 换成 let
for(let i=0; i<10; i++){ setTimeout(function(){ console.log(i) // 依次打印 0 到 9 },200) }
声明自执行函数
for(let i=0; i<10; i++){ ((j)=>{ setTimeout(function(){ console.log(j) // 依次打印 0 到 9 },200) })(i) }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
将 var 换成 let
声明自执行函数
The text was updated successfully, but these errors were encountered: