Last active
August 29, 2015 14:07
-
-
Save caomulaodao/82ed952f166077f15c51 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#数组去重 | |
Array.prototype.unique = function(){ | |
this.sort(); //先排序 | |
var res = [this[0]]; | |
for(var i = 1; i < this.length; i++){ | |
if(this[i] !== res[res.length - 1]){ | |
res.push(this[i]); | |
} | |
} | |
return res; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment