@Kuba In jQuery, I would use
extend. JavaScript doesn't have functions like that built in. So the answers to questions like that are very dependent on what libraries you are using. You can of course also do it with barebones JavaScript, but the solution will be some combination of for loops, not just one function.