Object.fromEntries is the inverse of Object.entries. It will take key-value pairs and return a new object. You can use it on Arrays and Maps.
We got Object.entries()
which converts an object → array. But what if you want to do the reverse? Wonder no more! Use Object.fromEntries()
to array → object 👏
const keyValuePair = [
['cow', '🐮'],
['pig', '🐷'],
];
Object.fromEntries(keyValuePair);
// { cow: '🐮', pig: '🐷' }
#javascript #web-development #developer