Explain the purpose of constructor() in Aurelia

 Posted by Rajnilari2015 on 8/24/2016 | Category: JavaScript Interview questions | Views: 2380 | Points: 40

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



Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response