Question

I'm having trouble with a Windows Scripting Host script.

Here is an example of problem input code:

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

The output is:

number
1.#QNAN

Shouldn't 'woot' be evaluating as a string? How can I get around this limitation?

Was it helpful?

Solution 3

I found a solution here:

Validate decimal numbers in JavaScript - IsNumeric()

Can a mod please close this request?

OTHER TIPS

Anything from parseInt is a number, since even NaN is treated a number by JS.Therefore, you'd need to check the type of 'woot' before you parseInt it.

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top