fromBase - Parses a string representation of a number in a given base
fromBase
will parse a string
value, representing some number, in a given base. For example, 01
in base 2
is equal to 1
in base 10
.
Syntax
Arguments
Name | Type | Required | Description |
---|---|---|---|
string | string | true | The string containing the number |
radix | number | true | The base for the string-number value. For example, hexidecimal has base 16 . |
Example - Parsing a hexidecimal string
Consider the following document:
Using the fromBase
function, we can parse this hexidecimal value into a number
type, which allows us to perform further numerical calculations.
This results in the following document:
This can also be written as a standalone function:
Theme
Light