Skip to content

Instantly share code, notes, and snippets.

@zhoumengkang
Created February 27, 2014 01:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zhoumengkang/9242766 to your computer and use it in GitHub Desktop.
Save zhoumengkang/9242766 to your computer and use it in GitHub Desktop.
js数组去重
/**
* 数组去重
* @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