How to assign the attribute value of A object to the same attribute in B object

B is the required attribute, but the value is the value corresponding to the attribute of the A object you want

The following operations can get the B object, and want to get the value

<js>
var A={
        name:'张三',
        age:'180',
        long:'180cm',
        hage:'手长',
        heard:'头发短',
        add:'地址:乱坟岗',
        money:'身价过亿',
 }
      
var B={
         money:'身亿',
         name:'三',
         age:'10',
}

for(let i in A)for(let k in B)if(i==k)B[i]=item[k]


输出B的结果为
B={
         money:'身价过亿',
         name:'张三',
         age:'180',
}
</js>

Scan the code to get 1000+ collections of front-end interview questions and try them out later

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_42981560/article/details/115010219