Hey there! I have a question about Angular 2 and Typescript that I'm hoping to get some clarity on. I've been following a tutorial (you can find it here) and noticed a change in the declaration of the heroes
variable in the app.component.ts
.
Initially, it was set as:
export class AppComponent {
heroes = HEROES;
}
But then it changed to:
export class AppComponent {
heroes: Hero[];
}
I grasp that the first declaration assigns the heroes array with a constant value, but I am unsure why the second one uses a colon instead of just an equal sign to assign an empty array. When I tried changing it back to =
, I ran into an "expression expected" error. Can someone explain the distinction between these two declarations?