get all the ids in an array of objects ts 1

get all the ids in an array of objects ts

array.map(s=>s.id)

Here is what the above code is Doing:
1. We’re using the map function to iterate over the array of objects.
2. We’re using the arrow function to return the id property of each object.
3. We’re using the spread operator to return the array of ids.

Similar Posts