Código Javascript:
Ver original
var Person = (function(win, doc, undefined) { var Person = function(fname, lname) { this.fname = fname; this.lname = lname; }; Person.prototype = { constructor : Person, toString : function() { return this.fname + " " + this.lname; }, getName : function() { return this.fname; }, setName : function(name) { this.fname = name; } }; return Person; })(window, document); var User = (function(win, doc, undefined) { var User = function(role) { this.role = role; }; User.prototype = { constructor : User, getRole : function() { return this.role; }, setRole : function(role) { this.role = role; } }; return User; })(window, document); // Aquí aplica la Herencia User.prototype = new Person('Juan', 'Garcia'); var jc = new User('admin'); jc.setName('Juan Carlos'); console.log(jc);
Si tienen algun link, libro, para recomendar de JS y POO se los agradecería.