How to merge two array object element in jquery
This question already has an answer here:
使用Object.assign
可能解决方案。
var b = [{"cat_id":"1","cat_name":"teaching"}], a = [{"username":"r","password":"r"}],
res2 = [Object.assign({}, ...a.concat(b))];
console.log(res2);
您可以使用带扩展语法的Object.assign()
。
var b = [{"cat_id": "1","cat_name": "teaching"}];
var a = [{"username": "r","password": "r"}];
var result = [Object.assign({}, ...a, ...b)]
console.log(result)
您可以使用扩展函数来合并对象
$.extend( a, b);
链接地址: http://www.djcxy.com/p/27350.html
上一篇: 如何在AngularJS的另一个对象内部推送一个对象?
下一篇: 如何在jquery中合并两个数组对象元素