Thursday, September 19, 2013

Good reasons against leading commas in Javascript

Good reasons against leading commas in Javascript

I recently joined a project where leading commas are used as a standard.
While I understand the reason of this style ( safe commenting of lines ),
It's very inconvenient (To put it mildly).
I have a strong feeling that it's not only about taste, and I need better
reasons than 'I don't like it' to convince the team not to use this style
..
Can you help me ?
Thanks.
p.s. Sample code:
function cls(){
var prop = {
a:'a'
,b:'b'
,c:'c'
,d:'d'
};
var arr = [
11
,12
,13
,14
];
var x=1
,y=2
,z=3;
return {
f:function(){
alert(prop.a);
}
, g:function(){
alert(arr[0]);
}
, h: function(){
alert(x);
}
};
}
var test = cls();
test.f();test.g();test.h();

No comments:

Post a Comment