Skip to content

Instantly share code, notes, and snippets.

@QETHAN
Created June 3, 2013 14:46
Show Gist options
  • Save QETHAN/5698697 to your computer and use it in GitHub Desktop.
Save QETHAN/5698697 to your computer and use it in GitHub Desktop.
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