Digital Garden
Computer Science
JavaScript
Objects, Classes and Prototypes

Objects, Classes and Prototypes

Info

Todo on objects and classes and the differences. Also clearly explain how prototypes work because atm i dont know.

Classes

Classes allow you to define blueprints for JavaScript objects. With classes you can also add inheritance to JavaScript objects.

class Human {
  species = "human";
}
class Person extends Human {
  name = "Max";
  printMyName = () => {
    console.log(this.name);
  }
}
const person = new Person();
person.printMyName(); // prints "Max"
console.log(person.species); // prints "human"