Skip to content

Instantly share code, notes, and snippets.

@smrchy
Created March 21, 2016 14:38
Show Gist options
  • Save smrchy/7160477369436c499fbd to your computer and use it in GitHub Desktop.
Save smrchy/7160477369436c499fbd to your computer and use it in GitHub Desktop.

Intersection / Difference / Union Hints

Which elements are new in new_array compared to old_array

old_array = [1, 4, 5]
new_array = [1, 2, 3, 4]

_.difference(new_array, old_array)

// [2, 3]

Which elements of old_array are missing in new_array

old_array = [1, 4, 5]
new_array = [1, 2, 3, 4]

_.difference(old_array, new_array)

// [5]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment