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
var arrys = []; for (var i = 0; i < 10; i++) { arrys.push(function () { return i; }); } arrys.forEach(function (fn) { console.log(fn()); }); //本⾏不能修改
The text was updated successfully, but these errors were encountered:
Sorry, something went wrong.
var arrys = []; for (var i = 0; i < 10; i++) { (function(_i){ arrys.push(function () { return _i; }); })(i); } arrys.forEach(function (fn) { console.log(fn()); }); //本⾏不能修改 // 方法二:let块级作用域 var arrys = []; for (let i = 0; i < 10; i++) { arrys.push(function () { return i; }); } arrys.forEach(function (fn) { console.log(fn()); }); //本⾏不能修改 // 方法三 var arrys = []; for (var i = 0; i < 10; i++) { arrys.push((function (_i) { return () => _i }(i))); } arrys.forEach(function (fn) { console.log(fn()); }); //本⾏不能修改
No branches or pull requests
The text was updated successfully, but these errors were encountered: