You often want to initialize certain fields and even trigger the execution of methods found when an object is newly
instantiated. There's nothing wrong with doing so immediately after instantiation.
But it would be easier if this were done for you automatically.Such a mechanism exists in OOP, known as a constructor.
|
function __constructor([argument1, argument2, ......, argumentN]) { // Class initialization code } |
Example:
Invloking Parent Constructors
|
class Employee function __constructor() class Manager extent Employee ------------------------------------------------------------------------- |