Skip to content

Instantly share code, notes, and snippets.

@mrchief
Created June 2, 2018 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrchief/faa92bca9079eec382e83da5c24efb07 to your computer and use it in GitHub Desktop.
Save mrchief/faa92bca9079eec382e83da5c24efb07 to your computer and use it in GitHub Desktop.
Simple array intersection check in ES6
/* Returns true if a intersects with b
* a is said to intersect with b if at least 1 element of a is present in b.
* e.g.
* intersects(['1', '2'], ['1', '3', '4']) // true
* intersects(['1', '2'], ['3', '4']) // false
*/
export default (a, b) => a.some(k => b.indexOf(k) > -1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment