ObjectLiteral :
{}
{ PropertyNameAndValueList }
{ PropertyNameAndValueList , }
You can use this syntax in all modern browsers [3]. It makes it easier to maintain the content inside object literals, especially long ones: You don’t have to keep track which property is last when rearranging things. Take the following example.
var obj = {
foo: 123,
bar: function () { ... },
}
Thanks to the trailing comma, you save two steps when swapping foo and bar, as there is no need to add a comma after bar or to remove the comma after foo. [Thanks to Brendan Eich for reminding me about trailing commas in ES5 object literals.]
Related reading: