Hai Tien
Hai Tien

Reputation: 3117

Error while compiling on closure-compiler

I want take shorten my JS, but Errors appear while compiling.

Error warning from points like :

default = {
        Home:'',
        Max: 5,
}

or

items: {
     visible: 1,
     width: 200
      }

Waring Msg :

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 162 character 0
visible: 1,

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 249 character 0
Home:'',

Say me how to solve this error.

Upvotes: 0

Views: 694

Answers (2)

John
John

Reputation: 5468

Your options are:

  1. turn down the ES3 diagnostic group to warning or off

  2. change the language mode to ECMASCRIPT5 or ECMASCRIPT5_STRICT. EcmaScript 5 standardized trailing comma behavior but IE8 and below will produce syntax errors if you try to run the code uncompiled

  3. correct the code to remove the trailing commas.

Upvotes: 0

dwaddell
dwaddell

Reputation: 1506

default = {
    Home:'',
    Max: 5,

}

needs to be

default = {
    Home:'',
    Max: 5

}

Upvotes: 3

Related Questions