码迷,mamicode.com
首页 > 编程语言 > 详细

js判断数组是否有重复值

时间:2018-07-05 14:59:08      阅读:112      评论:0      收藏:0      [点我收藏+]

标签:lse   hash   cti   log   判断   span   func   console   nbsp   

function isRepeat(arr) {
    var hash = {};
    for(var i in arr) {
       if(hash[arr[i]])
        return true;
        hash[arr[i]] = true;
    }
    return false;
}

var a = [1,2,34,5,1]

console.log(isRepeat(a))

 

js判断数组是否有重复值

标签:lse   hash   cti   log   判断   span   func   console   nbsp   

原文地址:https://www.cnblogs.com/bunuo/p/9267965.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!