Safe parseFloat alternative.
parseFloat
Parses a string to a float number. Returns undefined instead of NaN if it fails.
string
number
undefined
NaN
parseFloatingPoint(10); // 10parseFloatingPoint(13.10); // 13.1parseFloatingPoint("invalid"); // undefined Copy
parseFloatingPoint(10); // 10parseFloatingPoint(13.10); // 13.1parseFloatingPoint("invalid"); // undefined
undefineNaN
String to parse.
Parsed number or undefined if invalid.
Safe
parseFloat
alternative.Remarks
Parses a
string
to a floatnumber
. Returnsundefined
instead ofNaN
if it fails.Example
See
undefineNaN