Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 13, 2019 23:09
Show Gist options
  • Save parzibyte/c769bccda6c307f7b1e0f015124dec97 to your computer and use it in GitHub Desktop.
Save parzibyte/c769bccda6c307f7b1e0f015124dec97 to your computer and use it in GitHub Desktop.
/**
* Diferencia de arreglos en JavaScript
* Obtener elementos que existen en arreglo A pero no en arreglo B
*
* @author parzibyte
*
* https://parzibyte.me/blog
*
*/
// Obtener elementos que existen en un arreglo
// pero no en otro
const diferenciaDeArreglos = (arr1, arr2) => {
return arr1.filter(elemento => arr2.indexOf(elemento) == -1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment