- Array.prototype.unique = function()  
 
- {  
 
-     var n = {}, r = [], len = this.length, val, type;  
 
-     for (var i = 0; i < this.length; i++) {  
 
-         val = this[i];  
 
-         type = typeof val;  
 
-         if (!n[val]) {  
 
-             n[val] = [type];  
 
-             r.push(val);  
 
-         } else if (n[val].indexOf(type) < 0) {  
 
-             n[val].push(type);  
 
-             r.push(val);  
 
-         }  
 
-     }  
 
-     return r;  
 
- }  
 
 
思路源自于hpl大牛的思路,修正来自于CSDN社区的 i52nd  ,侵删。
高效数组去重方法
原文:http://www.cnblogs.com/kongzhijingwei/p/5920520.html