Correct way to filter out a specific key from an array of objects? [duplicate]

Solution 1:

Use Array.map to extract the id property value from each object.

const arr = [
  {
    "id": 1,
    "application": "Default Case Set",
    "errorSource": "CASEWORK",
    "message": 34,
    "stackTrace": 0,
    "date": 0,
    "user": 0
  },
  {
    "id": 2,
    "application": "Default",
    "errorSource": "CASEWORK",
    "message": 39,
    "stackTrace": 2,
    "date": 0,
    "user": 0
   }
]

const result = arr.map(e => e.id)
console.log(result)