![]() |
VOOZH | about |
The Object.fromEntries() method in JavaScript is a standard built-in object which is used to transform a list of key-value pairs into an object. This method returns a new object whose properties are given by the entries of the iterable.
Syntax:
Object.fromEntries( iterable )
Parameters: This method accepts a single parameter iterable which holds an iterable such as Array or Map or other objects implementing the iterable protocol.
Return value: This method always returns a new object whose properties are given by the entries of the iterable.
The below examples illustrate the Object.fromEntries() method in JavaScript:
Example 1: In this example, we will convert a Map into an Object using the Object.fromEntries() method in JavaScript.
Output:
Object { 1: 0, big: "small" }
Object { Geek1: "Intern", stipend: "Works basis" }
Example 2: In this example, we will convert an Array into an Object using the Object.fromEntries() method in JavaScript.
Output:
Object { 1: 0, big: "small", a: "z" }
Object { Geek1: "Intern", stipend: "Works basis" }
Example 3: In this example, we will see some other Conversions to objects using Object.fromEntries() method in JavaScript.
Output:
Object { type: "Get_the Value", geekno: "34", paid: "10" }
Object { val1: 336, val2: 1035, val3: 228 }
We have a complete list of Javascript Object methods, to check those please go through this JavaScript Object Complete Reference article.
Supported Browsers: The browsers supported by Object.fromEntries() method are listed below: