[removed] move objects from one array to another: Best approach?

后端 未结 7 637
臣服心动
臣服心动 2021-01-04 01:38

I have two arrays, called \'objects\' and \'appliedObjects\'. I\'m trying to come up with an elegant way in Javascript and/or Angular to move objects from one array to anot

7条回答
  •  借酒劲吻你
    2021-01-04 02:08

    You can use this oneliner as many times as many items you need to move from arr1 to arr2 just prepare check func

    arr2.push(arr1.splice(arr1.findIndex(arr1El => check(arr1El)),1)[0])
    

提交回复
热议问题