javascript 缺少分号 - jshint - 语法错误?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8107575/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 02:18:33  来源:igfitidea点击:

missing semicolon - jshint - syntax error?

javascript

提问by topek

Why does jshint.com say I'm missing a semi-colon here. Do I need to add parentheses, is this a syntax stipulation?

为什么 jshint.com 说我在这里缺少分号。我需要加括号吗,这是语法规定吗?

function fill_id(a,b) {
    return document.getElementById( a ).innerHTML = b;
}

回答by Anton Kovalyov

JSHint maintainer here.

JSHint 维护者在这里。

This has been fixed in our master branch. The website still uses the older (more stable) release, though.

这已在我们的主分支中修复。不过,该网站仍然使用较旧(更稳定)的版本。

回答by topek

jsHint does not like the assignment on the return statement. If you remove the return the message goes away. The message is probably misleading.

jsHint 不喜欢 return 语句上的赋值。如果您删除 return 消息就会消失。该消息可能具有误导性。