Consider the following array of objects:
data = [{x: 1, y: 2, z: 3}, {x: 4, y: 5, z: 6}, {x: 7, y: 8, z: 9}]
Is there a way to extract only the x
elements from these objects and create an array out of them? For example:
x = [1, 4, 7]
Can this be achieved without having to loop through each object individually?