Class Syntax Proposal, Complete With Arguments For and Examples.

Jonathan Dumaine jonathan.dumaine at
Sat Sep 17 15:28:09 PDT 2011

I would like to add my suggestion for js classes.

The key points are:

   - Constructors are functions named the same as the class.
   - Inside the class, *this* refers to the class instance.
   - Functions and variables are declared outside the constructor, inside
   the class block.
   - function and var keywords are optional after  private  or  public
   - Getters, Setters are optional, but often useful. My example could be
   very concise after removing comments, spacing and getters/setters.
   - When compiled & minified, this syntax would be nearly equivalent to the
   current proposal (size-wise).

Arguments & Warrant:

This form would be very recognizable to people familiar with classical
object oriented languages, yet it still maintains javascript's dynamic
nature and prototypal inheritance. Almost everything in this form of class
could be compiled to a prototypal form.

I also argue that this form of class is far more readable, which is a very
important trait as javascript applications become ever larger and more
as the web evolves.

Lastly, I definitely have to veto the private @ syntax as posted in
Brendan's TXJS slides. Apparently M. Night is also on the ECMA committee,
because having symbols act as both operators and special, prefixed accessors
would be quite a twist. :)

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

More information about the es-discuss mailing list