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


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM