Created
March 21, 2013 05:33
-
-
Save houoop/5210887 to your computer and use it in GitHub Desktop.
JS数组去重
This file contains 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.dedupe=function () { | |
var hash={},result=[], | |
hasown=Object.prototype.hasOwnProperty; | |
for (var i = this.length - 1; i >= 0; i--) { | |
if(!hasown.call(hash,this[i])){ | |
hash[this[i]]=1; | |
result.push(this[i]); | |
} | |
}; | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment