Answers for "get all the values in an array of object"

10

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
Posted by: Guest on April-23-2020
0

object get array of values

const data = {
    "2015": {
        "year": 2015,
        "cover": {}
    }
}

Object.entries(data).forEach(([key, value]) => console.log(key, value));
Posted by: Guest on May-06-2021

Code answers related to "get all the values in an array of object"

Code answers related to "Javascript"

Browse Popular Code Answers by Language