Created
March 13, 2018 19:19
Revisions
-
Woodsphreaker created this gist
Mar 13, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ const arr1 = [{id: 5, msg: 'hshh'}, {id: 56, msg: 'hshgdh'}, {id: 7, msg: 'hshh'}] const arr2 = [{id: 5, msg: 'hshh'}, {id: 6, msg: 'hshgdh'}, {id: 7, msg: 'hshh'}] const compare = (list1, list2) => { const map = new Map() for (let {id, msg} of list1) { map.set(id, msg) } return list2.filter(({id, msg}) => !map.has(id)) } compare(arr1, arr2)