Javascript Closure Compiler Error Trailing Comma?

Sam*_*Sam 3 javascript minify google-closure-compiler

当谷歌通过名为Closure Compiler的方便工具中缩小JavaScript时,它会出现以下错误(并且不会缩小某个内容):

错误数:1 JSC_TRAILING_COMMA:解析错误.IE8(及以下)将错误地解析数组和对象文字中的尾随逗号.如果您要定位较新版本的JS,请设置相应的language_in选项.在all.js的第389行第1字符

theme : 'default', // The theme of the slider (default, theme1, theme2, t...
Run Code Online (Sandbox Code Playgroud)

故障在哪里以及需要更改哪些以修复错误?

$(window).load(function(){
jQuery('#slider1').autoSlider({
    theme               : 'default',    // The theme of the slider (default, theme1, theme2, theme3)
    width               : '960',    // The width of the slider, 100% for auto full width, set to 0 it will take the width of the largest image
    autoHidePlayBtn     : true,     //
Run Code Online (Sandbox Code Playgroud)

Mat*_*att 9

错误(因为害怕简单地重写Closure Compiler错误所说的内容)是IE8及以下版本无法解析具有尾随逗号的对象文字和数组文字.

var obj = {
    a: 1,
    b: 2, // trailing comma is bad!
};
Run Code Online (Sandbox Code Playgroud)

......对......

var obj = {
    a: 1,
    b: 2 // no trailing comma!
};
Run Code Online (Sandbox Code Playgroud)

修复是删除尾随逗号.

  • 要添加 - EcmaScript版本3(IE8及更低版本,以及较旧的Firefox和其他旧浏览器)不允许在数组和ES5(当前规范)中使用尾随逗号. (2认同)