把right的值赋值给left
let left = {a:1,b:3} let right = {a:14,b:16,c:6} function main(left,right){ for(var i in left){ if(right.hasOwnProperty(i)){ left[i] = right[i] } } return left } console.log(main(left,right)) Object.entries(right).forEach(([key,value]) => { if(left.hasOwnProperty(key)){ left[key] = value } }) console.log(left)