3 ms·
A similar convention, often seen within the node community: https://npmjs.org/doc/coding-style.html#Comma-First https://npmjs.org/doc/coding-style.html#Comma-Fi
by ds_ 13y ago
A similar convention, often seen within the node community: https://npmjs.org/doc/coding-style.html#Comma-First https://npmjs.org/doc/coding-style.html#Comma-First
Personally, I find this ugly with very little benefit. It seems awkward to edit.
- mradmin 13y agoAgreed, I follow this styleguide: https://github.com/felixge/node-style-guide https://github.com/felixge/node-style-guide
- jaegerpicker 13y agoComma first is a great convention, it allows you to easily comment out an item in a list while debugging. for example: var test = [ "firstitem" , "seconditem" //, "thriditem_commented_out" //, "fourthitem_should_also_be_commented_out" ] Otherwise you have to do this: var test = [ "firstitem", "seconditem"//, //"thriditem", //"fourthitem" ] It's just a lot more cognitive overhead to not put the comma first.
- city41 13y agoThat's not true because the spec for JS allows the trailing comma. IE is the only browser that doesn't follow this. So if you are doing Node dev, the trailing comma is harmless.
- iaskwhy 13y agoYou realise it's the opposite for the first item, right? Code easier to read (and thus understand) is what everyone should aim for.
- jameswyse 13y agoI did this for a while, it's easier to spot missing commas and allows you to comment out lines (besides the first line) but I switched back because it was annoying to align :/