Mikeal, So, the Math object is "no good"?
Rick -- Sent from my Palm Pre On Sep 9, 2011 4:27 PM, Mikeal Rogers <[email protected]> wrote: I've used a few different javascript style guides over the years and the only thing I can remember being consistent across all of them is that only constructors get First letter casing. I have to admit that the few times I've seen people using First letter casing for non-constructors I've immediately decided that their code is no good, which is probably a little reactionary on my part. Crockford puts it well: "Constructor functions which must be used with the new prefix should start with a capital letter. JavaScript issues neither a compile-time warning nor a run-time warning if a required new is omitted. Bad things can happen if new is not used, so the capitalization convention is the only defense we have." -Mikeal PS. I've now more or less settled on Isaac's style guide which is used by npm https://github.com/isaacs/npm/blob/master/doc/coding-style.md although I do use semicolons on new lines after large var declarations because I find that newer developers think the statement ends ambiguously. On Sep 9, 2011, at September 9, 20111:06 PM, Rick Waldron wrote:Thanks for all the input. I'm actually aware of and have studied quite thoroughly both of the resources that were provided - I'm kind of a "stickler" for style guides. 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. Thanks Rick On Fri, Sep 9, 2011 at 3:11 PM, Tom Schuster <[email protected]> wrote: >var a = 10 > , b = 20 > , c = 30; Ugh the first time i saw this, i wondered who came up with this. The Google style guide also isn't too bad http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xmlcript.crockford.com/code.html , though I disagree with /wrong button On Fri, Sep 9, 2011 at 9:00 PM, Dmitry Soshnikov <[email protected]> wrote: > Also, style guides with 2 spaces indention are also good and wide-spread > (other things are the same as described in the link which Mark gave -- this > is Java's style guide by the way). > > On 09.09.2011 22:10, Mark S. Miller wrote: > > I like http://javascript.crockford.com/code.html , though I disagree with > leaving a space between "function" and "(" for anonymous functions. > > Since function name is optional in case of an expression, a space after the > function may make sense. > > function foo() {} > function () {} -- just name disappeared, all the other the same. > > Or, an analogy -- you put a space after some statements which are followed > by the parenthesis, right? E.g.: > > while (true) {} > if (false) {} > > the same with function. > > However, of course it's just a local style guides. E.g. in Erlang, space is > not put (as usually and in code of standard library) for function > expressions as in your variant: > > Double = fun(X) -> X * X. > (fun(X) X * X)(2) > > OTOH there, in contrast with JS, `fun`s don't have names. > > P.S.: Back to topic, the thing which I personally don't like is to put a > colon on a new line, as used in Node.js often: > > var a = 10 > , b = 20 > , c = 30; > > Of course it has advantages, e.g. for commenting one line, but literally > looks odd for me. > > But in general ECMAScript has no style guide. As well as there is no such > language as ECMAScript (I mean, it's the sample implementation which is > called ECMAScript), and all others are just local style guides. Usually > that's said, either Java's style guide is used, or the same but with 2 > spaces. > > Dmitry. > > > http://www.jslint.com/ > > On Fri, Sep 9, 2011 at 10:45 AM, Rick Waldron <[email protected]> > wrote: >> >> I was wondering if a canonical guide for ECMAScript style and conventions >> exists - specifically I'm curious to find out what the historic precedence, >> rules and reasoning behind the capitalization of constructors and built-in >> objects, ie. Array or Math. Even _more_ specifically, there exists a fairly >> common convention that first letter capitalization is generally reserved for >> constructors that expect to be paired with "new"... obviously this is not a >> hard rule, but I'm curious if any documentation or articles exist regarding >> the subject. >> Thanks! >> Rick >> _______________________________________________ >> es-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es-discuss >> > > > > -- > Cheers, > --MarkM > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > > _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss _______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

