Skip to content
Advertisement

How to generate key value pair objects from an array in typescript

I have an array of ids and wanted to make an array object with adding a key “id” on it in typescript

JavaScript

Advertisement

Answer

You can use Array#map as follows:

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement