Skip to content

Instantly share code, notes, and snippets.

@alejandrolechuga
Last active February 6, 2019 05:26
Show Gist options
  • Save alejandrolechuga/e75207b49e791b9150a35934cfc697d9 to your computer and use it in GitHub Desktop.
Save alejandrolechuga/e75207b49e791b9150a35934cfc697d9 to your computer and use it in GitHub Desktop.
Prototype
// Clase base
function Person(name, age) {
this.name = name;
this.age = age;
this.config = function () {};
}
Person.prototype.getName = function () {
return this.name;
};
Person.prototype.getAge = function () {
return this.age;
};
Person.prototype.saludo = function () {
console.log(`Hola soy ${this.getName()} tengo ${this.getAge()}`);
};
var alejandro = new Person('Alejandro', 12);
alejandro.saludo(); // 'Hola soy Alejandro tengo 12'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment