The Fauna service will be ending on May 30, 2025.

For more information on the service wind down, see our announcement and the Fauna Service End-of-Life FAQ.

string.parseNumber()

Convert a String to a Number.

Signature

parseNumber() => Number | Null

Description

Converts the calling String to a numeric Number.

The method attempts to parse the calling String in the following order:

The calling String isn’t changed.

Limitations

  • Leading and trailing whitespace are allowed.

  • Exponential notation is allowed.

  • Comma separators aren’t allowed.

Parameters

None

Return value

One of:

Type Description

Number

Value parsed from the calling String.

Null

Unable to parse calling String.

Examples

  1. Convert an exponential value:

    "1.7976931348623158e308".parseNumber()
    1.7976931348623157e+308
  2. Convert the String to a number larger than Number can hold:

    "1.7976931348623159e308".parseNumber()
    Math.Infinity
\