JavaScript ES6 Class



 JavaScript classes, introduced in ES6, are primarily syntactical sugar over JavaScript’s existing prototype-based inheritance. the category syntax doesn't introduce a replacement object-oriented inheritance model to JavaScript. In early ES5 using function expression.

existing Prototype based inheritance:

Defining classes:

Classes are actually “special functions”, and even as you'll define function expressions and performance declarations, the category syntax has two components: class expressions and sophistication declarations.

ES6 class

Benefits of Using class

Convenient, self-contained syntax.

A single, canonical thanks to emulate classes in JavaScript. before ES6, there have been several competing implementations in popular libraries.

More familiar to people from a class-based language background.