convert array of object to array javascript code example
Example 1: javascript object to array
const numbers = {
one: 1,
two: 2,
};
console.log(Object.values(numbers));
console.log(Object.entries(numbers));
Example 2: javascript object to array
fooArray = Object.entries(fooObj);
fooArray.forEach(([key, value]) => {
console.log(key);
console.log(value);
})
Example 3: how can i convert object to an array javascript
const entries = Object.entries(person);
console.log(entries);
Code language: JavaScript (javascript)
Example 4: js convert obj to array
const array = [
['key', 1],
['two', 2],
];
Object.fromEntries(array);