I was exploring the Angular official tutorial and stumbled upon an intriguing example of a simple class (https://angular.io/tutorial/toh-pt1). In this example, they demonstrated using the class as if it were an object, which left me puzzled.
class Hero{
id: number;
name: string
They showcased its usage like this...
const HEROES: Hero[] = [
{ id: 11, name: 'Mr. Nice' },
{ id: 12, name: 'Narco' },
{ id: 13, name: 'Bombasto' },
{ id: 14, name: 'Celeritas' },
];
This list was then utilized in the HTML code. (https://angular.io/tutorial/toh-pt2)
As someone new to Typescript, I found myself perplexed by this concept. In languages like Python, classes need to be instantiated to be used. While I am aware that objects can be created and utilized similarly in Javascript, I have never encountered it being done with the class keyword.
I embarked on a search through Google, watched various videos on Typescript, yet failed to find similar examples elsewhere. If anyone could guide me towards relevant documentation or provide a straightforward explanation with examples, I would greatly appreciate it!