parseFloatX(source: undefined | null | string): number | undefined
There are a lot of ways to convert a string to a number in JavaScript.
And they are all slightly different!
This is my preferred way to parse a number. The base comes from the
standard parseFloat command(). Any errors are reported as undefined,
so you can choose to get rid of them with ??.
I get rid of NaNs and infinities. I don't think I every really send
an infinity over the network or save it in a file. These become
undefined, just like errors.
There are a lot of ways to convert a string to a number in JavaScript. And they are all slightly different!
This is my preferred way to parse a number. The base comes from the standard parseFloat command(). Any errors are reported as undefined, so you can choose to get rid of them with ??.
I get rid of NaNs and infinities. I don't think I every really send an infinity over the network or save it in a file. These become undefined, just like errors.
Returns
A finite number or undefined if the parse failed.