js判断几个字符串是否有重复
var Rank1 = $('.rank').children('*:nth-child(1)').find('.rankLis span').text(); var Rank2 = $('.rank').children('*:nth-child(2)').find('.rankLis span').text(); var Rank3 = $('.rank').children('*:nth-child(3)').find('.rankLis span').text(); var Rank4 = $('.rank').children('*:nth-child(4)').find('.rankLis span').text(); console.log(Rank1) console.log(Rank2) console.log(Rank3) console.log(Rank4) //判断几个字符串是否有重复 var ary = new Array(Rank1,Rank2,Rank3,Rank4); var nary=ary.sort(); for(var i=0;i<ary.length;i++){ if (nary[i]==nary[i+1]){ console.log("数组重复内容:"+nary[i]); }
参考链接:https://zhidao.baidu.com/question/692544747795585524.html