let n = {
a: '',
b: '',
c: ''
}
let m = {
a: 'aaa',
b: 'bbb',
c: 'ccc',
d: 'ddd'
}
Object.keys(n).forEach(key => {
n[key] = m[key] || n[key]
})
console.log(n);
原文:https://blog.csdn.net/m0_47391133/article/details/113884261