Classes & Objects In JavaScript

Classes & Objects In JavaScript

Introduction To Classes & Objects

Classes and Objects were not part of JavaScript until ES6
A class is like a template or a blueprint based on which we will create real-world like Objects

Classes & Objects

Creating a Class

The following example represents how to create a class in JavaScript

Capture.JPG

Constructor In JavaScript Classes

The goal of the constructor is to basically initialize the parameters of the object

Capture.JPG

This keyword in JavaScript Classes

this will refer to the current class object when used inside a class

Capture.1JPG.JPG

Creating an object in JavaScript we use the new keyword

asCapture.JPG

Inheritance in JavaScript

The super keyword will call the parents Constructor

Captureasas.JPG