How to clone a Javascript Array of Objects?

后端 未结 7 1372
一向
一向 2020-12-09 19:10

I have a result set which is an array of objects. I need to clone this so I can make changes to it, without touching the original data.

var data = w2ui.grid.         


        
7条回答
  •  庸人自扰
    2020-12-09 20:05

    Lodash has a method specifically for this called clonedeep. There's a standalone package for it if you don't want to pull in the entire library:

    https://www.npmjs.com/package/lodash.clonedeep

提交回复
热议问题