如何在IE 11中合并对象
- 论坛
- 如何在IE 11中合并对象
8 浏览
如何在IE 11中合并对象
我有以下的对象数组:
Objs[0] = {Name : "ABC"}; Objs[1] = {Roll : 123}
我想将它变成以下的形式:
Objs { Name : "ABC", Roll : 123 }
我尝试使用以下代码实现:
var Objs = [{ Name: "ABC" }, { Roll: 123 }]; console.log( Object.assign.apply(null, [{}].concat(Objs)) // 1 ) 或者 console.log( Object.assign({}, ...Objs) // 2 )
问题是在IE 11中无法工作。
我得到以下错误:
Error for 1 : Unable to get property 'on' of undefined or null reference
Error for 2 : Object doesn't support property or method 'assign'
有没有关于如何在IE 11中合并对象的建议?