Skip to content

Tag: arrays

TypeScript enum to specific object

I have the following TypeScript enum: If I import it in my react application and console.log it, I will get the following object returned: How can I manipulate it, so that I get the following object returned? I tried it with const Lang = Object.keys(SupportedLanguages) and also with .map() but I did not get t…

How to convert Map to array of object?

i’m trying to convert a Map into array of object Lets say I have the following map: let myMap = new Map().set(‘a’, 1).set(‘b’, 2); And I want to convert the above map into the following: Answer You could take Array.from and map the key/value pairs.