Skip to content

Day 2: Prototypes & ES6 Classes

Model entities using ES6 Classes, constructors, and inheritance with extends.

class User {
constructor(name, email) {
this.name = name;
this.email = email;
}
greet() {
return `Hello, I am ${this.name}`;
}
}
class Admin extends User {
constructor(name, email, permissions) {
super(name, email);
this.permissions = permissions;
}
}
  1. Model a Vehicle base class and extend it with a Car subclass.