标签:bsp span function ++ rip col var prototype log
<script> // 重复 Array.prototype.unique3 = function(){ var res = []; var json = {}; console.log(this) for(var i = 0; i < this.length; i++){ if(!json[this[i]]){ res.push(this[i]); json[this[i]] = 1; } } return res; } function unique(arr){ var json={}; var res =[]; for(var i=0;i<arr.length;i++){ // arr[i] var item = arr[i]; if(!json[item]){ res.push(arr[i]); json[item]= 1; } } return res; } var arr = [112,112,34,‘你好‘,112,112,34,‘你好‘,‘str‘,‘str1‘]; console.log(arr.unique3()); console.log(‘test‘); console.log(unique(arr)); </script>
标签:bsp span function ++ rip col var prototype log
原文地址:http://www.cnblogs.com/alan-alan/p/7462803.html