javascript - Closure compiler issues with object -


i trying compile js code in google closure compiler , getting error on code

 var settings = { providers: ['a', 'b', 'c'], interface: 'basic16', apikey: 'xxxxx-xxxxx-xxxxx-xxxxxxxxxx' } 

errors are

jsc_parse_error: parse error. invalid property id @ line 3 character 10 interface: 'basic16', ^ jsc_parse_error: parse error. syntax error @ line 3 character 11 interface: 'basic16', ^ jsc_parse_error: parse error. syntax error @ line 4 character 8 apikey: 'xxxxx-xxxxx-xxxxx-xxxxxxxxxx' ^ 

but code works perfect me in browser (chrome, firefox, opera, safari, ie7,8,9)

the mdn states keyword interface reserved future use , may not used property/function/variable names.

https://developer.mozilla.org/en/javascript/reference/reserved_words

thing is, mdn states usage of keyword restricted when in strict mode. i'm not quite sure whether closure compiler doing right thing when complains in non-strict mode. looks more bug, it's better avoid using these keywords anyway.

however, solution wrap identifier in quotation marks:

var settings = { providers: ['a', 'b', 'c'], 'interface': 'basic16', apikey: 'xxxxx-xxxxx-xxxxx-xxxxxxxxxx' }; 

Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -