Why does nobody ever mention the obvious solution? Separate var statements.
They're always correct, they copy without any editing, and the "var"s line up to show that it's a block of assignments the same as commas or whitespace.
They're always correct, they copy without any editing, and the "var"s line up to show that it's a block of assignments the same as commas or whitespace.
var foo = 1,
bar = 2
baz = 3
In 90% of the cases the code will run the same whether or not there is a comma on line 2, but in the other 10% you will get burned in odd ways now that `baz` is a global variable.* There's a missing semicolon on line 2
* There's a missing semicolon on line 3
* baz was being used before it was defined.
That's just in a global context. When it's in a function you get a little more:
* the baz line is indented too far - because it's being interpreted as a new statement.
Sure, you could eyeball your code looking for this. Or just use an automated tool that'd do it for you
var a = 2; var b = 4; var c = { blah: "whatever" };
Leaving out a semicolon has no effect. They can be copied without any fuss. It's easy.
x = {[
{ id: 1, data: 0 },
{ id: 2, data: 0 }
],
[
{ id: 3, data: 0 },
{ id: 4, data: 0 }
]}