{
"name": "Bender"
, "hind": "Bitable"
, "shiny": true
}
Who puts commas at the start of a continuing line? What good could that possibly do? {
"name": "Bender"
, "hind": "Bitable"
, "shiny": true
}
Who puts commas at the start of a continuing line? What good could that possibly do?I've seen people do this in the SELECT portion of SQL queries too.
Personally, I hate this.
It also lets you remove the line (for the same reason that you can comment it out) without modifying other lines. This is somewhat convenient if the file is one that you are going to manually edit (and even more useful if it is going to be the subject of line-oriented diffing tools, since the only changed lines will be the ones with meaningful changes.)
I'd agree that its less readable, though.
select *
from foo
where 1=1
AND bar = 1
AND baz = 2
That way you can comment out any of your conditions without breaking the syntax. UPDATE FOO
SET BAR = 1
, BAZ = 2
, QUUX = 3
I like it that way. Makes it clear the relationship between the continuing lines and their parents. Just the natural extension of WHERE ALICE = 1
AND BOB =2
AND CHARLIE = 3In your example, I don't know SET BAR = 1 isn't the end until I read the next line.
I mean, it's kind of the SQL analogue to the
MyObject
.Child
.Grandchild
.ItsMethod(stuff)
.HeyThatReturnedAnotherObject()
.MoreObject(moreStuff)That would only be an advantage above comma at the end on the last line. It really only moves the problem from the last line to the first one. Now you can't comment out the first line without removing a comma...
It can make resolving merges just a little bit easier.
Some encourage this so you can comment out a line without having to add/remove commas. However, this isn't the case if you want to comment out the first line; so in effect, it just moves the problem from the bottom to the top of the list. Other proponents say it's easier to spot typos (i.e., missing commas). For example:
var something = {
foo: 'bar',
abc: '123'
quux: null,
xyz: 456
};
vs: var something = {
foo: 'bar'
, abc: '123'
quux: null
, xyz: 456
};
In the second one, it's clearer that there's a comma missing.Personally, I think it's ugly and, while I'm sure I've erroneously omitted commas before, they're caught by the parser. No example comes immediately to mind where missing a comma can be interpreted as something other than a parse error.
Here's an item there's going to be another one,
Or
Here's an item
, I'm another one
{ "name": "Bender"
, "hind": "Bitable"
, "shiny": true }