ES Style Question

Dmitry Soshnikov dmitry.soshnikov at
Fri Sep 9 12:00:09 PDT 2011

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 , 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.


> On Fri, Sep 9, 2011 at 10:45 AM, Rick Waldron <waldron.rick at 
> <mailto:waldron.rick at>> 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
>     es-discuss at <mailto:es-discuss at>
> -- 
>     Cheers,
>     --MarkM
> _______________________________________________
> es-discuss mailing list
> es-discuss at

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list