当前位置:网站首页>JS merge two objects (interview questions)

JS merge two objects (interview questions)

2022-06-11 11:24:00 kilito_ 01

const a ={
    a:1,b:2}
const b ={
    b:1,c:2}
//  Merging two objects 
function extend(target,source){
    
    for (const key in source) {
    
        target[key] = source[key]
    }
    return target
}
console.log(extend(a,b))
原网站

版权声明
本文为[kilito_ 01]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111108241644.html