JSFiddle - React, Tailwind, and code Playground
JavaScript
var a = {
id: 1,
qtde: 2
};
var b = {
id: 1,
nome: 'teste'
};
function mergeObjects(source, target) {
Object.keys(source).forEach(function(key) {
target[key] = source[key];
});
}
mergeObjects(a, b);
console.log(b); // Object {id: 1, nome: "teste", qtde: 2}