get array object value in javascript code example

Example 1: object to array javascript

Object.values(obj)

Example 2: get all entries in object as array hjs

const object1 = {
  a: 'somestring',
  b: 42
};

for (let [key, value] of Object.entries(object1)) {
  console.log(`${key}: ${value}`);
}

// expected output:
// "a: somestring"
// "b: 42"
// order is not guaranteed

Example 3: how to get array from object in javascript

let result = objArray.map(({ foo }) => foo)

Example 4: return an object from an array javascript

myArray.find(item => item.isAstronaut)