Skip to content

Instantly share code, notes, and snippets.

@titanew
Created May 22, 2013 16:07
Show Gist options
  • Save titanew/5628792 to your computer and use it in GitHub Desktop.
Save titanew/5628792 to your computer and use it in GitHub Desktop.
数组去重
Array.prototype.unique =
function() {
var a = [];
var l = this.length;
for(var i=0; i<l; i++) {
for(var j=i+1; j<l; j++) {
if (this[i] === this[j])
j = ++i;
}
a.push(this[i]);
}
return a;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment