presiannedyalkov
4/20/2020 - 3:06 PM

Reasign to another object

Useful for getting querystring parameters and assign them as aparameters to another object.

const object1 = {
  key1: value1,
  key2: value2
};
const object2 = {
  key3: value3
};
Object.keys(object1).forEach(function (key) {
	object2[key] = object1[key];
});
console.log(object2); // should return { key1: value1, key2: value2, key3: value3 }