Finding a "safety syntax" for classes

Gavin Barraclough barraclough at
Fri Mar 23 01:30:51 PDT 2012

On Mar 23, 2012, at 12:42 AM, Claus Reinke wrote:

> - would it make sense to name the constructor after the class
>   (avoiding 'constructor' and 'new')?

I was about to suggest exactly the same thing.

If I see a line of code saying
    let x = new FooBar();
and want to understand what it does, I'm instinctively looking for a function named FooBar, not one named either 'new' or 'constructor'.

Between 'new' and 'constructor', new seems like the better choice to me.  Whilst it is true that prototypes currently contain a constructor property, I don't see a lot of code that explicitly accesses this.  In terms of the language actually actively in use in scripts by ES programmers, 'new' is currently in the common lexicon, and 'constructor' doesn't seem to be.  [ I make this statement on casual observation rather than any empirical evidence. :-) ]


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

More information about the es-discuss mailing list