原生js简单数组去重
<script type="text/javascript"> var a = ['1','2','3','a','1','a','3','4',2] var arr1 = []; $(a); function $(arr){ for( var i = 0;i<arr.length;i++){ if(arr.indexOf(arr[i])==i){ arr1.push(arr[i]); } } alert(arr1); } </script>
原生js简单数组去重
<script type="text/javascript"> var a = ['1','2','3','a','1','a','3','4',2] var arr1 = []; $(a); function $(arr){ for( var i = 0;i<arr.length;i++){ if(arr.indexOf(arr[i])==i){ arr1.push(arr[i]); } } alert(arr1); } </script>