How to merge object in IE 11

IE11 does not support Object.assign.

You could iterate the array and the keys and take the values as new property of the result object.

var objs = [{ Name: "ABC" }, { Roll: 123 }],
    result =  objs.reduce(function (r, o) {
        Object.keys(o).forEach(function (k) {
            r[k] = o[k];
        });
        return r;
    }, {});

console.log(result);

Install:

npm i -s babel-polyfill

And at the top of entry index.js file add:

import 'babel-polyfill'

This will solve some issues that Babel did not. Object.assign is one of them.

This means you can use new built-ins like Promise or WeakMap, static methods like Array.from or Object.assign, instance methods like Array.prototype.includes, and generator functions (provided you use the regenerator plugin). The polyfill adds to the global scope as well as native prototypes like String in order to do this.

For the end, you will need to decide whether you want to use the whole babel-polyfill (which is around 50kb minimized) or to use only what you need through individual polyfills, ie. es6-promise for Promises.


You can use jQuery method $.extend() which work in IE 11.

var object = {name: 'John', surname: 'Rowland'};
var newObject = $.extend({}, object);

newObject.age = '30';

console.log(object);
console.log(newObject)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>