You can use the map()
method to retrieve an array of specific object key values. Here is an example:
index.tsx191 chars10 lines
In the example above, we have an array of objects myObjects
. We want an array of the id
values. We use the map()
method to iterate over each object, and return only the id
value. The result is stored in myArray
variable. Finally, we log the array to the console.
gistlibby LogSnag