Created
June 22, 2020 13:22
-
-
Save justinehell/7575f9bf1629a343e45b122a32fa31ca to your computer and use it in GitHub Desktop.
POO en JS 1 - Procédural vs Objet, classes, instances
This file contains 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
class Person { | |
constructor(name, age) { | |
this.name = name; | |
this.age = age; | |
} | |
tellMyName() { | |
console.log(`I am ${this.name}`) | |
} | |
tellMyAge() { | |
console.log(`I am ${this.age} old`) | |
} | |
}; | |
const firstPerson = new Person('John', 40); | |
const secondPerson = new Person('Mary', 35); | |
firstPerson.tellMyName(); | |
firstPerson.tellMyAge(); | |
secondPerson.tellMyName(); | |
secondPerson.tellMyAge(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment