标签:
<body> <script> var arr = [1, 1,1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6,"a","a"]; var sub = []; //遍历 arr.forEach(function(value){ //indexOf查找里面的值,如果有则返回下标,否则返回-1; var index =sub.indexOf(value); if (index == -1) { sub.push(value); } })
标签:
原文地址:http://www.cnblogs.com/ysq642055416/p/5593217.html