How do I compare two variables containing strings in JavaScript?

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

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



        
4条回答
  •  不思量自难忘°
    2020-12-30 02:22

    You can use javascript dedicate string compare method string1.localeCompare(string2). it will five you -1 if the string not equals, 0 for strings equal and 1 if string1 is sorted after string2.

    
    

提交回复
热议问题