1.

Explain The Purpose Of Constructor() In Aurelia?

Answer»

Constructor METHOD is used for initializing object CREATED with a CLASS. This method is called first. If we don't specify this method, the default constructor will be used.

For example
export class App
{
constructor()
{
this.counter = 1;
}
}

here we are initializing teh counter property to 1 inside the constructor. Later we can use this in the view and display the value as 1 like

${counter}

Constructor method is used for initializing object created with a class. This method is called first. If we don't specify this method, the default constructor will be used.

For example
export class App
{
constructor()
{
this.counter = 1;
}
}

here we are initializing teh counter property to 1 inside the constructor. Later we can use this in the view and display the value as 1 like

${counter}



Discussion

No Comment Found