欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

JS移除数组中重复数据

程序员文章站 2022-03-04 12:49:27
...
<script>
var arrs = ["11","22","33","44","55","666"];
function unq(arrs ) {
  var result = [], hash = {};
  for (var i = 0, elem; (elem = arr[i]) != null; i++) {
    if (!hash[elem]) {
      result.push(elem);
      hash[elem] = true;
    }
  }
  return result;
}
console.info(unq(arrs ));
</script>