Minimalist Classes

Erik Corry erik.corry at gmail.com
Wed Nov 2 05:28:13 PDT 2011


Here's a simple super suggestion:

super Foo.bar(x) should desugar to Foo.prototype.bar.call(this, x)

If people make constructors of the type that are designed to be called
with new then it works for constructors too.

// Works with super, used with var foo = new Foo.prototype.constructor()
constructor: function() {
  this.x = 0;
  this.y = 0;
}

// Doesn't work with super, used with var foo = Foo.prototype.constructor()
constructor: function() {
  return {x: 0, y: 0}
}

// Also doesn't work with super
constructor: function() {
  var self = factory();
  self.x = 0;
  self.y = 0;
  return self;
}


-- 
Erik Corry


More information about the es-discuss mailing list