Skip to content Skip to sidebar Skip to footer

The Object.entries() method in JavaScript is used to return an array of a given object’s own enumerable properties, in the same order as that provided by a for…in loop. The entries are returned as an array of key-value pairs, where the key is the property name and the value is the corresponding value of that property.




const obj = { a: 1, b: 2, c: 3 };
console.log(Object.entries(obj)); // [["a", 1], ["b", 2], ["c", 3]]

This method is useful in cases where you need to process all the properties of an object or pass them around in a more convenient way. It is also useful when working with APIs that require an array of key-value pairs instead of an object.

Copyright © 2023. All rights reserved.

Copyright © 2023. All rights reserved.