Algorithm to get changes between two arrays

后端 未结 8 1375
难免孤独
难免孤独 2021-02-04 05:43

I needed to create an algorithm which will (efficiently) take an old array and a new array and give me back the changes between the two (which items added, which removed). It ha

8条回答
  •  抹茶落季
    2021-02-04 06:33

    The following page has a function that removes one array from another and can be used to give you the 2 values. Remove items from a JavaScript Array with RemoveArrayItems()

    var newItemsAdded=RemoveArrayItems(oldArray,newArray);
    var ItemsRemoved =RemoveArrayItems(newArray,oldArray);
    

提交回复
热议问题