How To Map Object/Dict To Array (ES6 JavaScript, Lodash)

December 16, 2017
from _ import lodash

const object = {
  name: 'Desmond Lua',
  age: 37,
  country: 'Malaysia'
}

const list = _.map(object, (value, key) => `${key}: ${value}`)

console.log(list)

Output

["name: Desmond Lua", "age: 37", "country: Malaysia"]
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.