Skip to content

Instantly share code, notes, and snippets.

@drifterz28
Created February 22, 2013 14:07
Show Gist options
  • Save drifterz28/5013637 to your computer and use it in GitHub Desktop.
Save drifterz28/5013637 to your computer and use it in GitHub Desktop.
Array.prototype.unique = function (sort, sortingFunction) {
var array = [];
for (var i = 0; i < this.length; i++) {
if (array.inArray(this[i]) === false)
array.push(this[i]);
}
if (sort === true) {
if (typeof sortingFunction === 'function')
array.sort(sortingFunction);
else
array.sort();
}
return array;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment