Javascript string/integer comparisons

后端 未结 8 1076
太阳男子
太阳男子 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:19

    You can use Number() function also since it converts the object argument to a number that represents the object's value.

    Eg: javascript:alert( Number("2") > Number("10"))

提交回复
热议问题