I am looking to simplify my variable declaration process for an array in my Angular 8 project using TypeScript.
Currently, my code looks like this:
export class GridComponent {
pizza0: Pizza;
pizza1: Pizza;
pizza2: Pizza;
pizza3: Pizza;
pizza4: Pizza;
pizza5: Pizza;
constructor() {}
}
interface Pizza {
name: string;
ingredients: number;
price: string;
}
I want to streamline this process by doing something like:
PizzaList: Array<Pizza> = new Array<Pizza>(pizza0, pizza1, pizza2, pizza3, pizza4, pizza5);
interface Pizza {
name: string;
ingredients: number;
price: string;
}
Each variable should be declared initially within the array.