class Animal {
constructor(name) {
this.name = name;
}
speak() {
return `${this.name} makes a sound.`;
}
}
const dog = new Animal('Rex');
dog.speak(); // 'Rex makes a sound.'- Classes are NOT hoisted the same way functions are (they stay in the TDZ)
- Class bodies always run in strict mode
- Methods defined on the class live on the prototype, not each instance