Last active
February 6, 2019 05:26
-
-
Save alejandrolechuga/e75207b49e791b9150a35934cfc697d9 to your computer and use it in GitHub Desktop.
Prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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