(Built-in) way in JavaScript to check if a string is a valid number

前端 未结 30 3356
-上瘾入骨i
-上瘾入骨i 2020-11-22 01:54

I\'m hoping there\'s something in the same conceptual space as the old VB6 IsNumeric() function?

30条回答
  •  迷失自我
    2020-11-22 02:35

    Well, I'm using this one I made...

    It's been working so far:

    function checkNumber(value) {
        return value % 1 == 0;
    }
    

    If you spot any problem with it, tell me, please.

提交回复
热议问题