I want to combine the following arrays of objects by first joining the id property
var arr1 = [{ id: 1, name: 'fred', title: 'boss' },{ id: 2, name: 'jim', title: 'nobody' },{ id: 3, name: 'bob', title: 'dancer' }]; var arr2 = [{ id: 1, wage: '300', rate: 'day' },{ id: 2, wage: '10', rate: 'hour' },{ id: 3, wage: '500', rate: 'week' }];
Thus, the result will be
[{ id: 1, name: 'fred', title: 'boss', wage: '300', rate: 'day' },{ id: 2, name: 'jim', title: 'nobody', wage: '10', rate: 'hour' },{ id: 3, name: 'bob', title: 'dancer', wage: '500', rate: 'week' }]
I would like to avoid using js frameworks (if possible), although ExtJs is already part of the project. At the moment when I have a loop with an inner loop, if the keys match, it copies the properties and breaks out of the inner loop to start the next outer loop.
Any best deals?