I wanted to do something which is very straight-forward using Object.assign
.
var firstObj = {name : "Saba H.", rollNo : 1};
var secondObj = {college : "WCE"};
var wholeObj = Object.assign(firstObj, secondObj);
console.log(wholeObj); // {name : "Saba H.", rollNo : 1, college : "WCE"}
As Object.assign
is part of ECMAScript6 harmony proposal and not supported across many browsers, is it possible to do with ES5? If not then is there any micro library?