Created
June 3, 2013 14:46
-
-
Save QETHAN/5698697 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
1.Array.prototype.unique = function(){ | |
var results=this.sort() | |
for ( var i = 1; i < results.length; i++ ) { | |
if ( results[i] === results[ i - 1 ] ) { | |
results.splice( i--, 1 ); | |
} | |
} | |
return results; | |
} | |
alert(new Array('你好','你好').unique()); | |
</script> | |
2. 直接使用JQuery.unique(array)方法 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment