javascript - Intance and prototype in one line of code -
sample code set situation:
function parent() { //code } function child() { //code } child.prototype = object.create(parent.prototype); var objchild = new child();
is possible write last 2 lines in one?
edit: came mind while writing kind of code repeteadly. i'm not after specific thing here. wanted know if possible.
you wrap in function , pass parent class.
function parent() { //code } function child(parentclass) { function childobj() { } childobj.prototype = object.create(parentclass.prototype); return new childobj(); } var objchild = child(parent);
Comments
Post a Comment