var a = function(){ this.sayFoo = function(){ console.log('foo'); }; } var b = function(){ console.log(this.prototype); //undefined this.sayBar = function(){ console.log('bar'); }; } b.prototype = new a(); var bInst = new b(); bInst.sayFoo(); bInst.sayBar(); console.log(b.prototype); //a {sayFoo: function} How do I add sayBar to the b prototype inside the function constructor?
Does b.prototype = new a(); overwrite the prototype, or merge b's with a's?