[removed] Can a comma occur after the last set of values in an array?

后端 未结 3 1136
抹茶落季
抹茶落季 2020-12-03 10:03

I am wondering if a comma trailing an array in javascript is valid?

var settings = {
    \'foo\'  : oof,
    \'bar\' : rab,
};

vs



        
3条回答
  •  醉酒成梦
    2020-12-03 10:22

    Most browsers and implementations do allow a trailing comma, the big BUT is the "Internet Explorer".

    A trailing comma in most InternetExplorer versions causes BIG trouble. It'll throw wierd, crazy, strange and unreasonable errors .. you have no idea where you're at! This is terrible, you'll fall into deep and serious depressions. The disease also has a name, "evil comma of doom" it was called once.

    Conclusion: NEVER.. ever! use a trailing comma in Javascript.

提交回复
热议问题