Skip to content

Instantly share code, notes, and snippets.

@popomore
Created November 27, 2013 11:45
Show Gist options
  • Save popomore/7674405 to your computer and use it in GitHub Desktop.
Save popomore/7674405 to your computer and use it in GitHub Desktop.
数组去重
Array.prototype.uniq = function() {
return this.filter(function(item, index, arr) {
return index === arr.indexOf(item);
});
};
// test
[1,2,3,2,1,2,4,6,8,3,2].uniq();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment