使用Google Closure Compiler我收到此错误:
JSC_TRAILING_COMMA: Parse error. IE8 (and below) will parse trailing commas in array and object literals incorrectly. If you are targeting newer versions of JS, set the appropriate language_in option. at line 7 character 9
},
对于以下代码:
App.prototype = {
testA: function () {
},
testB: function () {
},
};
我想知道是否 jshint有一些内置选项可以检测尾随逗号并显示警告消息。
最佳答案
JSHint 会警告您 "Extra comma. (it breaks older versions of IE)"如果您设置 es3
选项(在版本 2.0.0 及更高版本中):
/*jshint es3: true */
var x = {
prop1: 10,
prop2: 20,
};
在旧版本的 JSHint 中,您不需要设置 es3
选项,因为它是默认选项。所有版本的 JSLint 也会给出类似的警告。
关于javascript - JSC_TRAILING_COMMA : Parse error. IE8(及更低版本)- jshint 可以警告我左尾随逗号吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29119285/