After diving into the proposed JavaScript features, one that caught my attention is the idea of supporting trailing commas in object literals and arrays.
When it comes to parameters, trailing commas are not relevant, so let's put that aside for now. I can see the advantages for version control, but my concern lies in how it will interact with JSON.
const arr = [
'red',
'green',
'blue',
];
This example would be considered valid under the new rule.
However, what happens when we start working with JSON syntax? Since JSON follows RFC standards, it's unlikely that trailing commas will ever be accepted. But who knows what the future holds...
The real question is: How will JavaScript handle a return statement like this:
const jsonReturn = [{
"derp":1
}, {
"foo":"bar"
}, {
"slide":true,
},];
Will the trailing comma automatically get removed if the content type is JSON, or will it cause everything to break?