Advanced
+75 XP

👋 Start learning JavaScript right now — for free!

📖

Classes in JavaScript

Understand object-oriented programming with classes

🏭

Class = factory

A factory (class) produces identical products (objects). There is a mould (template), and the factory stamps out as many as needed. For example, the class Car — is a mould for cars. Each car is a separate object with the same properties, but different values.

javascript
💬

A class is a template. new Animal() — creates an object from the template.

javascript
💬

extends lets you create a new class based on an existing one.

Classes are syntactic sugar on top of objects and prototypes. Under the hood JavaScript still uses objects, but classes make the code more readable and structured.

Comments

Log In or Start to leave a comment.