Skip to content

Instantly share code, notes, and snippets.

@alejandrolechuga
Created February 6, 2019 05:45
Show Gist options
  • Save alejandrolechuga/2b9f656a5994e0b259ad33861e31cfc4 to your computer and use it in GitHub Desktop.
Save alejandrolechuga/2b9f656a5994e0b259ad33861e31cfc4 to your computer and use it in GitHub Desktop.
prototype
function Doctor(name, age) {
}
Doctor.prototype = Object.create(Person.prototype);
Doctor.prototype.saludo = function() {
console.log(`Saludos soy el doctor ${this.getName()} y tengo ${this.getAge()} años`);
};
var doctorAlejandro = new Doctor('Alejandro', 33);
doctorAlejandro.saludo(); // 'Saludos soy el doctor Alejandro y tengo 33 años'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment