Curried function to parse strings to numbers based on different radixes.
Parses a string to a number with the given radix, returning undefined instead of NaN if it fails.
string
number
radix
undefined
NaN
const parseDecimal = parseInteger(10);parseDecimal("101"); // 101parseDecimal("101.5"); // 101parseDecimal("invalid"); // undefined Copy
const parseDecimal = parseInteger(10);parseDecimal("101"); // 101parseDecimal("101.5"); // 101parseDecimal("invalid"); // undefined
undefineNaN
Radix to use for parsing (16 for hexadecimal, 10 for decimal, and so on).
16
10
Curried function with radix in context.
Curried function with radix set.
String to parse.
Parsed number or undefined if it fails.
Curried function to parse strings to numbers based on different radixes.
Remarks
Parses a
string
to anumber
with the givenradix
, returningundefined
instead ofNaN
if it fails.Example
See
undefineNaN