Skip to content

Instantly share code, notes, and snippets.

@romaefGit
Created October 29, 2019 20:04
Show Gist options
  • Select an option

  • Save romaefGit/8d3c56fc60ed8b2328519af850d38381 to your computer and use it in GitHub Desktop.

Select an option

Save romaefGit/8d3c56fc60ed8b2328519af850d38381 to your computer and use it in GitHub Desktop.
JavaScript - Arreglo único de indices normales
/**
* [uniquesArraySimply Duvelve un arreglo sencillo sin items repetidos:
example : arreglo ENVIADO = ['1',0,1,'2']
arreglo RETURN = [0,1,'2']]
* @param {[Array]} arr [El areglo normalito.]
* @return {[Array]} [El arreglo sin indices repetidos]
*/
var function = uniquesArraySimply(arr) {
var a = [];
for (var i = 0, l = arr.length; i < l; i++)
if (a.indexOf(arr[i]) === -1 && arr[i] !== '') a.push(arr[i]);
return a;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment