Thanks, Allan!
Allan Odgaard wrote:
I added the second version of the prototype snippet (but with open brace on a new line, to match the function snippet -- I don’t know if there’s a de-facto brace standard for JS!?!).
Like other C-like languages, I think it's mainly a matter of taste and the uniformity of having them both the same is the important thing.
JavaScript is a little bit different in that the code has to be sent to the client (typical use, not counting widgets et al.) before it can be interpreted. That being the case, you'll often see people reducing variable names down to a single character in sufficiently encapsulated code. While descriptive names are usually preferred, you can usually get away with it in JS. That being said, having the brace not requiring an extra linefeed can save you a few extra bytes in a long script.
But then, there are JavaScript compactors on the net that pretty much eliminate whitespace entirely, so we come back to it just being a matter of taste or going along with convention.
Mike