Created
February 27, 2014 01:57
-
-
Save zhoumengkang/9242766 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
/** | |
* 数组去重 | |
* @param array arr 去重数组 | |
* @return array 已去重的数组 | |
*/ | |
var unique = function(arr) | |
{ | |
var obj = {}; | |
for(var i = 0, j = arr.length; i < j; i++) { | |
obj[arr[i]] = true; | |
} | |
var data = []; | |
for(var i in obj) { | |
data.push[i]; | |
} | |
return data; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment