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

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -