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

给i赋值后,i变成了abc, abc++<3不成立。所以直接结束循环 #160

Closed
Moments28 opened this issue Mar 30, 2020 · 1 comment
Closed

Comments

@Moments28
Copy link

for (var i = 0; i < 3; i++) {
  var i = 'abc';
  console.log(i);
}
// abc

这里为什么会只输出一个abc呢??求教

Originally posted by @brushbird in #82 (comment)

@mqyqingfeng
Copy link
Owner

因为没有单独的作用域,第一遍循环的时候就修改了 i 的值为 abc,所以不会接着执行了

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

No branches or pull requests

2 participants