Skip to content

Instantly share code, notes, and snippets.

@luislobo14rap
Last active August 23, 2018 01:12
Show Gist options
  • Save luislobo14rap/eb1fb243f3c5682f635237cff59c657a to your computer and use it in GitHub Desktop.
Save luislobo14rap/eb1fb243f3c5682f635237cff59c657a to your computer and use it in GitHub Desktop.
// arrayUnique.js v1
function arrayUnique(array) {
let newArray = [];
for (let i = 0; i < array.length; i++) {
if (newArray.indexOf(array[i]) == -1) {
newArray.push(array[i]);
};
};
return newArray;
};
Array.prototype.unique = function() {
return arrayUnique(this);
};
// arrayUnique.min.js v1
function arrayUnique(a){let b=[];for(let c=0;c<a.length;c++)-1==b.indexOf(a[c])&&b.push(a[c]);return b}Array.prototype.unique=function(){return arrayUnique(this)};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment