<html> <head> <title>js过滤数组中重复 </title> </head> <body> <script> //过滤数组中重复 var uniq = function (arr) { var a = [], o = {}, i, v, len = arr.length; if (len < 2) { return arr; } for (i = 0; i < len; i++) { v = arr[i]; if (o[v] !== 1) { a.push(v); o[v] = 1; } } return a; } var x = new Array("www","dwwwcn","wwwdwwwcn","dwwwcn"); alert(x); var y = uniq(x); alert(y); </script> </body> </html>
当前位置:主页 >> JavaScript >> 正文
js过滤数组中重复的值
阅读:4021 输入:2014-11-12 15:18:46