Please help - I want to merge and extend JavaScript objects in a way like in example below:
var objects = [{
id: 1,
fruits: "apple"
},{
id: 1,
fruits: "bannana"
},{
id: 2,
fruits: "tangerine"
},{
id: 2,
fruits: "plum"
}];
and to have results like:
var results = [{
id: 1,
fruits: ["apple", "bannana"]
},{
id: 2,
fruits: ["tangerine", "plum"]
}];
Is there any JavaScript, jQuery or easy custom solution to do it? It is different situation then here How can I merge properties of two JavaScript objects dynamically? or also $.expand() does not do here what I want. Thanks a lot!