-1

I have a below source array of objects

[
  {
    'joa Doe 1': 'Joe Doe 3',
    '[email protected]': '[email protected]',
    __rowNum__: 2
  },
  {
    'joa Doe 1': 'Joe Doe 3',
    '[email protected]': '[email protected]',
    __rowNum__: 2
  }
]

I want output something like below

[
  {
    'joa Doe 1': 'Joe Doe 3',
    '[email protected]': '[email protected]'
  },
  {
    'joa Doe 1': 'Joe Doe 3',
    '[email protected]': '[email protected]'
  }
]

Can someone please help me how to filter the array or copy to new one by excluding the rownum element form the object form array. I'm new to javascript

mu shaikh
  • 83
  • 6

1 Answers1

2

You can just using Array.map() to do it.

let data = [
  {
    'joa Doe 1': 'Joe Doe 3',
    '[email protected]': '[email protected]',
    __rowNum__: 2
  },
  {
    'joa Doe 1': 'Joe Doe 3',
    '[email protected]': '[email protected]',
    __rowNum__: 2
  }
]

data = data.map(({__rowNum__,...rest}) => rest )
console.log(data)
trincot
  • 317,000
  • 35
  • 244
  • 286
flyingfox
  • 13,414
  • 3
  • 24
  • 39