Tip #41[Object.entries / Object.fromEntries]

The Object.entries method allows you to obtain entries of a given JavaScript object:

It can be used as an input for creating a JavaScript Map instance, therefore it comes handy when you want to convert an object into a map:

Another common scenario when the Object.entries method is useful is when you want to map an object’s properties.

You can easily convert back to an object with the aid of the Object.fromEntries method:

Live example:

If you like the tip, please give me some applause 👏

--

--