admin 管理员组文章数量: 1086019
In the chrome console, I can't run any loops. Why is this?
For example, the following will give a syntax error of "Expected '('"
for each (var item in [1, 2, 3]) alert(item)
In the chrome console, I can't run any loops. Why is this?
For example, the following will give a syntax error of "Expected '('"
for each (var item in [1, 2, 3]) alert(item)
Share
Improve this question
asked Aug 8, 2010 at 17:06
VerhogenVerhogen
28.7k35 gold badges93 silver badges109 bronze badges
2 Answers
Reset to default 5each
isn't a Javascript keyword. See the W3Schools page on Javascript's for
statement for reference.
Try the following:
for ( var item in [1,2,3] ) alert(item)
It's been a long time since the question is posted. I'm a new user and just found out one more way or a better way to do it.
[1, 2, 3].forEach( el => alert(el))
Hope this also may help someone.
本文标签: Chrome Developer Console Can39t Run JS LoopsStack Overflow
版权声明:本文标题:Chrome Developer Console Can't Run JS Loops - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1744091256a2532077.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论