In an Array Initialization and Object Instance declaration, last item with a comma should be valid syntax

Topics: Language Specification
Aug 8, 2013 at 4:00 AM
It would be nice (and JS seems ok with it), if these were not syntax errors:
var arr = [ 

var obj = {
    foo: 'foo',
    bar: 'bar',
Would make it much nicer when add/removing, or rearranging items/properties. Does anyone else agree?
Aug 8, 2013 at 9:21 AM
I agree, although this is only valid ES5, so it should probably only work with that target.
Aug 8, 2013 at 3:16 PM
IE 6 and 7 will fail to parse JavaScript with trailing commas. Google's Closure Compiler will also mark it as an error.
Aug 8, 2013 at 3:26 PM
Well, not all JS interpreters/vm's are created equal, but it doesn't matter. TypesScript could be just fine with it and remove from the generated JS; that's all I was sayin'.