-2

I have this object result:

[{"id":1},{"id":2},{"id":3}]

How can I convert this to

[1,2,3]

in Lodash?

Code Geek
  • 755
  • 2
  • 6
  • 17

1 Answers1

3

You don't need lodash for this, you can do this easy to achieve with a map function.

var x = [{"id":1},{"id":2},{"id":3}]

var y = x.map(n => n.id);
console.log({y})
painotpi
  • 6,894
  • 1
  • 37
  • 70