ES6 Converting Object to an Array

by Dani Arlandis — on

How to converting object to an array with ES6

Full article: https://www.samanthaming.com/tidbits/76-converting-object-to-array/

Full object reference https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object

const zoo = {
  lion: '🦁',
  panda: '🐼',
};

Object.keys(zoo);
// ['lion', 'panda']

Object.values(zoo);
// ['🦁', '🐼']

Object.entries(zoo);
// [ ['lion', '🦁'], ['panda', '🐼'] ]

Enjoy it.