Multi Inheritance in JavaScript -


why type of inheritance not work in javascript. there way perform step. please help

function base() {} base.prototype.findfirst = function() {     console.log("findme first"); }  function base2() {} base2.prototype.findme = function() {     console.log("findme "); }  function inherit() {     base.call(this);     base2.call(this); }  inherit.prototype = base.prototype; inherit.prototype.constructor = inherit; inherit.prototype = base2.prototype; inherit.prototype.constructor = inherit;  var test = inherit(); test.findfirst(); test.findme(); 

you overwritting prototype base.prototype , base2.prototype. stores base2.prtotype i.e. assigned second. if create instance of inherit class var test = new inherit(); see test has base2.property i.e. has fimeme() method in test.property.findme();. achieve goal should try extend or refer mixin multiple inheritance


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -