Skip to content

Instantly share code, notes, and snippets.

@RodrigoNovais
Last active May 24, 2021 18:19
Show Gist options
  • Save RodrigoNovais/80ea03f51a65bf734a981a1209c3ed2d to your computer and use it in GitHub Desktop.
Save RodrigoNovais/80ea03f51a65bf734a981a1209c3ed2d to your computer and use it in GitHub Desktop.
Returns the values from array that are not present in the other arrays
/**
* Returns the values from array that are not present in the other arrays
*
* @param {unknown[]} first
* @param {unknown[]} second
* @returns {unknown[]}
*/
export const difference = (first: unknown[], second: unknown[]): unknown[] => {
return first.filter(item => !second.includes(item));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment