const Person = {
firstName: 'abc',
lastName: 'xyz',
age: 50
};
const result = Object.entries(Person);
console.log(result);
Output:
[
[ 'firstName', 'abc' ],
[ 'lastName', 'xyz' ],
[ 'age', 50 ]
]
- Above code will convert the properties of the
Personobject into an array of key-value pairs usingObject.entries(). Object.entries(Person): takes each property of thePersonobject and convert it into an array, where each element is a[key, value]pair.