Convert a hexadecimal string to a bigint. This verifies that the string is a valid hex string. Both "0x"-prefixed and unprefixed strings are supported.
bigint
To convert a hexadecimal string to a number instead, use hexToNumber.
hexToBigInt('0x0'); // 0nhexToBigInt('0x1'); // 1nhexToBigInt('0x10'); // 16n
The bigint.
If the value is not a valid hexadecimal string.
The hexadecimal string to convert to a bigint.
Convert a hexadecimal string to a
bigint
. This verifies that the string is a valid hex string. Both "0x"-prefixed and unprefixed strings are supported.To convert a hexadecimal string to a number instead, use hexToNumber.
Example
Returns
The
bigint
.Throws
If the value is not a valid hexadecimal string.