3 ms·
> var one = "foo" , two = "bar" , three = "baz" Agree with the author that this is easier to change, and in JS it will keep you from accidentally leaving
by meistro 13y ago
> var one = "foo"
, two = "bar"
, three = "baz"
Agree with the author that this is easier to change, and in JS it will keep you from accidentally leaving a trailing comma. That being said, I find it to be very unreadable(which is where most your time will be spent) and most text editors/IDE's make it a burden to work with.
- sonnym 13y agoWhile I agree with making code editable in single lines as much as possible, I think this is a particularly bad example. I do prefer the comma first style for arrays and objects, but not for variable declarations. I used to use this exact style a couple years ago, but now I prefer to explicitly declare every variable with `var` to prevent any possible, syntactically correct, error that would result in a global variable.
- ryanpetrich 13y agoIt's even easier to create three separate var statements and let a JavaScript compressor handle it: var one = "foo"; var two = "bar"; var three = "baz";