How do I compare two variables containing strings in JavaScript?

前端 未结 4 606
太阳男子
太阳男子 2020-12-30 01:34

I want compare two variables, that are strings, but I am getting an error.



        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-30 02:12

    I used below function to compare two strings and It is working good.

    function CompareUserId (first, second)
    {
    
       var regex = new RegExp('^' + first+ '$', 'i');
       if (regex.test(second)) 
       {
            return true;
       }
       else 
       {
            return false;
       }
       return false;
    }
    

提交回复
热议问题