Tip 39 Extend Existing Prototypes with Class

In this tip, you’ll learn how to use classes with existing prototypes.

Now that you know how to write classes in JavaScript, it’s time to see how the new class syntax relates to JavaScript prototypes. It’s important to understand that classes in JavaScript and prototypes aren’t different. Classes are just a clean way to write regular JavaScript. By understanding how classes in JavaScript differ from traditional object-oriented languages, you’ll be able to integrate new syntax with legacy code and prevent subtle bugs from surfacing.

What are the differences between JavaScript and more traditional object-oriented languages? Here are the basics: When you use a class in traditional object-oriented languages, ...

Get Simplifying JavaScript now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.