Loading, please wait...

Constructor

Object Constructor

Object constructor helps to create an object type which is used again and again to meet the requirement of the user.

In JavaScript, the constructor function name will be the object type name.

Here, “this” operator is used to refer to the current object. There is no return statement in the constructor function.

 

Syntax

function person (name, age, salary)
{
    this.name = name;
    this.age = age;
    this.salary = salary;
}