Union of Array of Objects in JavaScript?

前端 未结 6 936
予麋鹿
予麋鹿 2020-12-03 12:11

So after searching the interwebz for a few hours I have not found the solution I am looking for.

I have two arrays that contain game objects with a lot of informatio

6条回答
  •  情歌与酒
    2020-12-03 12:44

    Using underscore extend, you can do:

    var objects = [{ bar : 1, nuts : 2} , {foo : 3, nuts : 4}]
    _.extend.apply(this,objects)
    

    If the list can be empty, make sure to append an empty object to it.

提交回复
热议问题