Merging objects (associative arrays)

前端 未结 16 1221
野的像风
野的像风 2020-12-04 08:20

What’s the best/standard way of merging two associative arrays in JavaScript? Does everyone just do it by rolling their own for loop?

16条回答
  •  攒了一身酷
    2020-12-04 08:53

    1. In Javascript there is no notion of associative array, there are objects
    2. The only way to merge two objects is to loop for their properties and copy pointers to their values that are not primitive types and values for primitive types to another instance

提交回复
热议问题