The Evolution of Inheritance

Prototypes are powerful but their syntax can be confusing. Modern JavaScript uses Classes — but they are just cleaner syntax over the same prototype system.

Classes Are Prototypes in Disguise

// Modern class syntax:
class Animal {
  constructor(name) { this.name = name; }
  eat() { console.log(this.name + ' is eating.'); }
}

// What JavaScript actually does under the hood:
function Animal(name) { this.name = name; }
Animal.prototype.eat = function() {
  console.log(this.name + ' is eating.');
};
// Identical result!

Why Classes Are Better

  • Cleaner: All code grouped inside one class { } block.
  • Safer: Can't be called without new — you get a clear error.
  • Easier inheritance: extends and super replace manual prototype linking.
Important

Understanding prototypes makes you a better developer because you know what's really happening under the hood when you use classes. Classes are covered in full detail in Module 10!