Skip to content

Instantly share code, notes, and snippets.

@justinehell
Created June 22, 2020 13:22
Show Gist options
  • Save justinehell/7575f9bf1629a343e45b122a32fa31ca to your computer and use it in GitHub Desktop.
Save justinehell/7575f9bf1629a343e45b122a32fa31ca to your computer and use it in GitHub Desktop.
POO en JS 1 - Procédural vs Objet, classes, instances
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