Re: new

Mon, 17 Oct 2011 02:16:24 -0700

I do the same with

Object.prototype.new = function () {
  var o = Object.create(this);
  o.constructor && o.constructor.apply(o, arguments);
  return o;
}

However rather then calling proto.new(); I would like var o = new proto();
and o instanceof proto to work

On Oct 17, 2011 9:17 AM, "Irakli Gozalishvili" <rfo...@gmail.com> wrote:

I think we should just forget about new keyword, prototype property all
togather and move towards something more simple:

var proto = {   method: function() { },
  new: function() {
    var self = Object.create(this);
    this.initialize.apply(self, arguments);
    return self;
  },
  initialize: function(someValue) {
    this.things = someValue
  }
}

var o = proto.new(someValue);

Of course with a help of library that would not require as much boilerplate:
https://github.com/Gozala/selfish


Regards
--
Irakli Gozalishvili
Web: http://www.jeditoolkit.com/
Address: 29 Rue Saint-Georges, 75009 Paris, France <http://goo.gl/maps/3CHu>

On Tuesday, 2011-10-11 at 20:53 , Jake Verbaten wrote:

 > > is there any kind of proposal for syntax that is like : > > var proto =
{ >   method: function(...
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to