JavaScript Tutorial

The language for programming web pages.

JS Classes

JavaScript Classes

Classes are a template for creating objects. They encapsulate data with code to work on that data. ES6 introduced class syntax as a cleaner way to work with prototypes.

Class Features:

  • constructor() — Initialize object
  • Methods — Functions inside class
  • extends — Inheritance
  • super() — Call parent constructor
  • static — Class-level methods
  • Getters/Setters — get/set

Try It Yourself

Edit the code below and click Run to see the result live.

Source Code
Result
Topics