Re: JavaScript/ECMAScript Styling and Citation

> TBH, It's unenforceable unless there's proper tooling. I'd leave it
> open and have a page discussing the various styles pros and cons.

Though technically unenforceable (for now?), I think it would still be beneficial to have official guidelines to point people to.  A discussion on pros and cons is well and good, but flavor-of-the-week style in examples would just be confusing.  Better to have a little official consistency and something to back it up than to have no consistency.

> i) a + 1; //returns 5

This is simply wrong; "return" has a specific meaning in JS (returning a value from a function).  Better not to confuse that with anything else.

> ii) a + 1; // 5

I like this style.  However, the python dev in me is saying "Explicit is better than implicit", and there's an implicit verb here. "//is 5" is the closest thing that's not implicit, so I'll throw my vote in there.

> iii) console.log(a + 1); //prints 5
> iv) document.write(a + 1); //prints 5
> v) a + 1 = 5

These should not be things.

> vi) a + 1; //=> 5

Looks too much like a valid syntax for my taste.  Better to use English in the comments, I think.

> I strongly favor vi, here.

When did this become about editors? :P

Andrew

Received on Wednesday, 17 October 2012 12:28:58 UTC