Are trailing commas standard in JavaScript, or do most browsers like Chrome and Firefox just tolerate them?
I thought they were standard, but IE8 puked after encount
Let's break this down.
Are trailing commas standard in JavaScript?
Yes. As of the ECMAScript 5 specification (also part of the Google and Airbnb style guide)
Do most browsers like Chrome and Firefox just tolerate them?
This is an ECMAScript 5 support question.
Transpilers like Babel will remove the additional trailing comma in the transpiled code which means you don’t have to worry about the trailing comma problem in legacy browsers.
So that means:
var heroes = [
'Batman',
'Superman',
];
// heroes.length === 2 (not 3)
So chances are if you're using anything ES5 and up you don't need to worry about it.
I thought they were standard, but IE8 puked after encountering one—of course IE not supporting something hardly means it’s not standard.
Again, that's an ECMAScript 5 support question. IE8 doesn't support ECMAScript 5 (only IE9 and up)
I would highly recommend taking a look Airbnb's ES5 deprecated Documentation https://github.com/airbnb/javascript/blob/es5-deprecated/es5/README.md#commas
I would also recommend the Mozilla's Docs:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Trailing_commas