Converts a string or number representing a numeric value into a number.
#x
Number()
0x
0b
0o
The numeric value parsed from the input. If parsing fails, returns NaN.
NaN
hexDecValueToNumber(42); // returns 42hexDecValueToNumber("#x2A"); // returns 42 (hexadecimal 2A)hexDecValueToNumber("42"); // returns 42 (decimal)hexDecValueToNumber("0x2A"); // returns 42 (hexadecimal)hexDecValueToNumber("0b101010"); // returns 42 (binary)hexDecValueToNumber("0o52"); // returns 42 (octal)
The input value to convert. Can be a number or a string representing a numeric value with optional prefixes.
Generated using TypeDoc
Converts a string or number representing a numeric value into a number.
#x
, it is parsed as a hexadecimal number.Number()
, which supports decimal, hexadecimal (0x
), binary (0b
), octal (0o
), and floating-point literals.Returns
The numeric value parsed from the input. If parsing fails, returns
NaN
.Example