function Person(){ this.name = 'Person'; }; Person.prototype.getName = function(){ return this.name; }; var person = new Person(); console.log(person.getName());//Person
function Person(){ this.name = 'Person'; }; Person.prototype.getName = function(){ return this.name; }; var person = new Person();// Person var Bar = function() { this.name = "Bar"; }; Bar.prototype = person.__proto__; var bar = new Bar(); bar.constructor = Bar; console.log(bar.getName());// Bar