Dorong properti dan nilai ke objek di JavaScript

var obj = {key1: "value1", key2: "value2"};
Object.assign(obj, {key3: "value3"});

document.body.innerHTML = JSON.stringify(obj);
 Run code snippetHide results
Precious Pygmy