JavaScript Revision Part 04

JavaScript Revision Part 04

Classical OOOPS JavaScript

JavaScript is designed to support classical OOPS. However, in ES6 classical OOPS was introduced in JavaScript

Note

  1. While writing a method/function inside a class it is not compulsory to mention the function keyword as the scope of the function is where it is declared.
  2. We can access methods outside the class unless they are made private using an instance of the object
  3. Private members were included in ES6
  4. this in a class refers to the current of the object of the class 5.Using new keyword an instance of the class can be created

Constructor

This is a special function with keyword constructor Is called automatically the moment we create an The physical object constructor() {

}

Private Members

  1. Variables and methods can be made private by adding a prefix '#' 2.This means we cannot access them outside the class