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 ...

Get Simplifying JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.