Constructor in Javascript ES6
CONSTRUCTOR :
The
constructor([arguments]) { ... }
The
constructor
method is a special method for creating and initializing an object created with a class
.
There can only be one special method with the name "constructor" in a class. A Syntax error will be thrown, if the class contains more than one occurrence of a
constructor
method.
A constructor can use the
super
keyword to call the constructor of a parent class.
If you don't specify a constructor method, a default constructor is used.
Example : -
Please click on this link https://googlechrome.github.io/samples/classes-es6/index.html for a better example.
Example : -
Please click on this link https://googlechrome.github.io/samples/classes-es6/index.html for a better example.
Comments
Post a Comment