Difference between two arrays of coffeescript objects using js underscore

I am trying to find the difference between two arrays of objects using the js underscore library.

+6
source share
1 answer

Do you want to use the underline markup function? You can do it:

_.difference([1, 2, 3, 4, 5], [5, 2, 10]) 

this works in coffeescript.

EDIT

Using an array of objects and comparing the id property

 arrayOne = [{id: 1}, {id: 2}] arrayTwo =[{id: 2}, {id: 3}] _.select arrayOne, (item) -> !_.findWhere(arrayTwo, {id: item.id}) 
+13
source

Source: https://habr.com/ru/post/972861/


All Articles