Skip to content

Instantly share code, notes, and snippets.

@h2rd
Created December 21, 2011 16:15
Show Gist options
  • Save h2rd/1506591 to your computer and use it in GitHub Desktop.
Save h2rd/1506591 to your computer and use it in GitHub Desktop.
var unique = function(origArr) {
var newArr = [],
origLen = origArr.length,
found,
x, y;
for ( x = 0; x < origLen; x++ ) {
found = undefined;
for ( y = 0; y < newArr.length; y++ ) {
if ( origArr[x] === newArr[y] ) {
found = true;
break;
}
}
if ( !found) newArr.push( origArr[x] );
}
return newArr;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment