Create an array of Objects and fill it with initial values in Typescript
Obviously, it's an ordinary case, when you get an array of objects and you need to create for the reply the array of other Objects, but you need to initialize it on load. For React developers it can be often used with useEffect or componentDidMount.
For example, you got the array:
const matchesData = await this._apiRep.getMatches();
And you need to create an array of the same size with some values from it. 'Map' will help you.
let defaultForecasts:IMatchForecast[] = matchesData.map(x => {
return (
{
betId: x.id??0,
home: 0, away: 0, userId: 1
}
)
})
As a result, you initialize the array and fill it with required properties.

Login as another user in SharePoint 2019 on-premises site in Chrome
Set limited Wi-Fi connection within command line in Windows
A sticker problem with the fan in HP laptop