我在Windows脚本脚本脚本上遇到了麻烦。

这是问题输入代码的示例:

WScript.Echo(typeof(parseInt('woot')))
WScript.Echo(parseInt('woot'))

输出是:

number
1.#QNAN

不应该作为字符串评估“ woot”吗?我该如何解决这个限制?

有帮助吗?

解决方案 3

我在这里找到了一个解决方案:

验证JavaScript中的十进制数字-Numeric()

mod可以关闭此请求吗?

其他提示

Parseint中的任何内容都是一个数字,因为即使是NAN的数字也可以通过J。因此,您需要在parseInt之前检查“ Woot”的类型。

You can check if parseInt return NaN (not a number)

isNaN(parseInt('woot', 10))

typeof return number becouse NaN is number in JavaScript

But remember that isNaN is litle bit broken read more#Examples

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top