JS实现合并json对象的方法

<script> function extend(des, src, override){ if(src instanceof Array){ for(var i = 0, len = src.length; i < len; i++) extend(des, src[i], override); } for( var i in src){ if(override || !(i in des)){ des[i] = src[i]; } } return des; } var a ={"a":"1","b":"2"} var b ={"c":"3","d":"4","e":"5"} var c = extend({}, [a,b]); console.log(c); </script>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyzyxz.html