Array of Objects in JavaScript

I am stuck in one scenario.

I have two objects Custpmer = [{id :1 , name:John},{id:2,name:Alice}]; purchase = [{userid :2 , purchase:240},{userid:1, purchase:250}]…n elements;

I need output which prints : Id name purchase.

Can anyone guide me on this.

It seems you’re getting this data from an API or a NoSQL DB. One approach is handling it as an array of JObject, I strongly recommend that you filter your data on the API Call or Query to avoid over complications when parsing the JSON.

Here is the reference to JObject