Answers for "js convert objec tot array"

1

converting object to array in js

const numbers = {
  one: 1,
};

const objectArray = Object.entries(numbers);

objectArray.forEach(([key, value]) => {
  console.log(key); // 'one'
  console.log(value); // 1
});
Posted by: Guest on July-22-2020
0

js convert obj to array

const array = [
  ['key', 1],
  ['two', 2],
];

Object.fromEntries(array);
// { one: 1, two: 2 }
Posted by: Guest on August-19-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language