Object.assign可以合并具有相同属性的对象,对象去重

Object.assign可以合并具有相同属性的对象,对象去重

let a = {
    
    name: 'kate',sex:'男' }
let c = {
    
    b:'b'}
let d = {
    
    c: '77'}
let other = Object.assign({
    
    },a,{
    
    name:"kaifan"},d)
console.log(other)  // { name: 'kaifan', sex: '男', c: '77', b: 'b' }

猜你喜欢

转载自blog.csdn.net/weixin_43131046/article/details/127078355