Javascript string/integer comparisons

后端 未结 8 1081
太阳男子
太阳男子 2020-11-22 16:34

I store some parameters client-side in HTML and then need to compare them as integers. Unfortunately I have come across a serious bug that I cannot explain. The bug seems to

8条回答
  •  醉话见心
    2020-11-22 17:17

    Parse the string into an integer using parseInt:

    javascript:alert(parseInt("2", 10)>parseInt("10", 10))
    

提交回复
热议问题