What's the difference between this:
export class List {
categories: any[];
constructor() {
this.categories = ['First Class', 'Second Class', 'Economy'];
}
}
And this:
export class List {
categories: any[] = ['First Class', 'Second Class', 'Economy'];
constructor() {
}
}
Both compile to the same Javascript code. Considering, in this particular example, the class is never going to be instantiated with passed in values, am I OK sticking with the second option of setting the values outside the constructor function?
This is in the context of Angular2 class components using typescript.