The class operator: a bridge between object and function exemplers

Waldemar Horwat waldemar at google.com
Mon Nov 14 14:53:39 PST 2011


On 11/14/2011 12:16 PM, Allen Wirfs-Brock wrote:
> /UnaryExpression/ :
> *class* /UnaryExpression/
> ...
>
> The semantics are:
> 1. if /UnaryExpression/ is undefined or null, return the value of /UnaryExpression/.
> 2. Let /obj/ be ToObject(/UnaryExpression/)
> 3. Return the result of calling the [[Get]] internal method of /obj/ with argument 'constructor'
>
> Using the class Operator
>
> Prefixing an object exemplar with the class operator turns it into a class exemplar:
>
> let Point = class {
> x:0,
> y,0,
> constructor(x,y} {
> this.x=x;
> this.y=y;
> }
> };

I don't understand what you're accomplishing here.  The above appears to be equivalent (modulo the typos) to:

let Point = function(x, y) {
   this.x = x;
   this.y = y;
};

The other stuff inside the class is ignored.

     Waldemar


More information about the es-discuss mailing list