admin管理员组文章数量:1289702
I receive this error,
Expected an identifier and instead saw ')'.
in this lines of code. Any how to fix it?
for (; index < nPageFullItemCnt; index++) {
strIndex = "0" + index;
keyIndex = "popup_item_" + strIndex.substr(strIndex.length - 2, 2);
keyItem = document.getElementById(keyIndex);
setPopupKeyText(keyIndex, " ");
keyItem.className = "popupLangItemNone";
keyItem.langId = "";
}
I receive this error,
Expected an identifier and instead saw ')'.
in this lines of code. Any how to fix it?
for (; index < nPageFullItemCnt; index++) {
strIndex = "0" + index;
keyIndex = "popup_item_" + strIndex.substr(strIndex.length - 2, 2);
keyItem = document.getElementById(keyIndex);
setPopupKeyText(keyIndex, " ");
keyItem.className = "popupLangItemNone";
keyItem.langId = "";
}
Share
Improve this question
edited Dec 20, 2012 at 12:49
Muthu Kumaran
17.9k5 gold badges50 silver badges72 bronze badges
asked Dec 20, 2012 at 12:40
GibboKGibboK
74k147 gold badges451 silver badges674 bronze badges
3
- What line number does it say, and what are the previous lines of your code? – AlanFoster Commented Dec 20, 2012 at 12:42
- The error isn't happening within this code block. You need to share more code. – Bartek Commented Dec 20, 2012 at 12:43
- 3 You have to know that JSLint is a very strict code quality tool that makes errors of what isn't really a big deal. Try using JSHint instead, it's more merciful. – Joseph Commented Dec 20, 2012 at 12:44
2 Answers
Reset to default 2You're not passing in the first parameter to the for()
loop:
for (index = 0; index < nPageFullItemCnt; index++)
{
/* .. */
}
This bit:
for (; index
Is causing that error. The code should validate if you do this:
for (0; index
(As I assume you're not passing the first parameter, on purpose)
However, I'd suggest using a while
loop, instead of a for, if you're not going to make use of the [initialization]; [condition]; [final-expression]
properties in a for
loop.
while(index < nPageFullItemCnt){
// Do stuff;
index++;
}
Technically, the 3 parameters are all optional, but some code validators can throw a error if they're missing.
本文标签: javascriptExpected an identifier and instead saw 39)39Stack Overflow
版权声明:本文标题:javascript - Expected an identifier and instead saw ')' - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741445578a2379178.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论