Skip to content

Instantly share code, notes, and snippets.

@martinandersen3d
Created December 12, 2017 04:16
Show Gist options
  • Save martinandersen3d/3de7d509699d1fd41fa6807cdbb989fb to your computer and use it in GitHub Desktop.
Save martinandersen3d/3de7d509699d1fd41fa6807cdbb989fb to your computer and use it in GitHub Desktop.
Compare two arrays, arrA must have all the items that is in arrB
/**
* Returns TRUE if the first specified array contains all elements
* from the second one. FALSE otherwise.
*
* @param {array} superset
* @param {array} subset
*
* @returns {boolean}
*/
function arrayContainsArray (superset, subset) {
if (0 === subset.length) {
return false;
}
return subset.every(function (value) {
return (superset.indexOf(value) >= 0);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment