Answers for "get array of object properties javascript"

2

get array of all property in object array

objArray = [ { foo: 1, bar: 2}, { foo: 3, bar: 4}, { foo: 5, bar: 6} ];
let result = objArray.map(a => a.foo); //[1,3,5]
//OR
let result = objArray.map(({ foo }) => foo) //[1,3,5]
Posted by: Guest on April-20-2021
34

object keys javascript

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

console.log(Object.keys(object1));
// expected output: Array ["a", "b", "c"]
Posted by: Guest on March-12-2020

Code answers related to "get array of object properties javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language