Suppose I have an array of objects. My goal is to generate a new array that exclusively contains the key values from those objects stored in the initial array. The catch here is that the number of elements in the original array, denoted by x, is uncertain as it depends on user input. Is there a feasible solution? I've experimented with mapping, filtering, and object.values()
, but all these methods end up producing an array of objects.
x = [{1: 182}, {2: 912}, {3: 51}, …]
y = [182, 912, 51, ...]