Constructor
Syntax
// This is a generic default constructor class Default
function
Default
(
)
{
}
// This is an overloaded constructor class Overloaded
// with parameter arguments
function
Overloaded
(
arg1,
arg2,
/* …, */
argN)
{
}
To call the constructor of the class in JavaScript, use a new
operator to assign a new object reference
to a variable
.
function
Default
(
)
{
}
// A new reference of a Default object assigned to a
// local variable defaultReference
const
defaultReference =
new
Default
(
)
;
See also
- Constructor on Wikipedia
- The constructor in object oriented programming for JavaScript on datarist
- New operator in JavaScript on datarist