ES Style Question

Wes Garland wes at page.ca
Fri Sep 9 13:48:11 PDT 2011


On 9 September 2011 16:06, Rick Waldron <waldron.rick at gmail.com> wrote:

> I was actually very specifically looking for an answer regarding First
> letter casing for non-constructor built-in objects, ie. Math and Proxy. I
> think the legacy Java style guide influence addresses the question as best
> as I can hope for.
>

These  *did* come to us via Java (well, not Proxy), but they are hardly a
matter of style; they are a matter of specification.

Generally we name constructor functions with CapitalLeadingCamelCase and
everything else with smallLeadingCamelCase.  I think I picked this up from
JavaScript: The Definitive Guide, 2nd Edition, by David Flanagan, about
4,000 years ago.

As for other matters of style, I am a big proponent of brace-on-a-line in
C-syntax languages, however this has proven to be a problem in practice with
JavaScript due to the interaction between automatic semicolin insertion and
object literal syntax in return statements:

return
{
  Hello: "world"
};

is not the same as

return {
  Hello: "world"
}

Wes

-- 
Wesley W. Garland
Director, Product Development
PageMail, Inc.
+1 613 542 2787 x 102
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110909/ec5de355/attachment.html>


More information about the es-discuss mailing list