I want to create a constructor that has an object as its prototype.
For example:
var constructor=function(){
this.foo=bar;
}
var constructorProto={
method:function(){}
}
constructor.__proto__=constructorProto;
constructor.method();
new constructor;
Functional demo: http://jsfiddle.net/juwt5o97/
This allows me to pass the constructor along and modify it before calling new. However, I don't want to use __proto__ or Object.setPrototypeOf(). Is there a "proper" way of doing this?
Object.setPrototypeOf()is not "proper"?constructor.method=constructorProto.method;, or use Extend or Object.create() to copy.__proto__. Regardless, it's ES6 and I'd prefer if there's a method that works with ES5.