Assuming I have two Javascript Objects
(they have a JSON
structure, but are created with JSON.parse()
). All entries have a unique ID
with which the entries from both objects can be matched.
What would be the fastest way to join both objects (native javascript
).
The first thing that comes into my mind would be a nested for in loop
.
for(var i in firstJson) {
for(var j in secondJson) {
if(firstJson[i].id === secondJson[j].id) {
// join them
}
}
}
Is there a faster way?