Tuesday, March 14

Java Script ES6 Custom Classes


Introduction

Most languages have support for objects. JavaScript has had support for objects for a long time, but now thanks to version ES6 we now have support for making custom classes. Below is example code of how easy it is to achieve this.

Example Code


class ClassName {

   constructor() {

       // Initialization Code
       this.variable = 'value';

   }

}


class SubClass extends ClassName

   constructor() {

       // Call parent’s constructor method
       super();

       // Initialization Code
       this.variable = 'value';

   }

}

0 comments :

Post a Comment