Syntax error What is a default constructor in JavaScript?

What is a default constructor in JavaScript?



If a constructor method is not added, then a default constructor should be used. A default constructor is created when nothing is defined.

Syntax

Here’s the syntax −

constructor() {}

The syntax for derived class −

constructor(...args) {
   super(...args);
}
Updated on: 2020-06-12T14:04:17+05:30

826 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements