parseNumber()

Convert the calling string to a Number.

Signature

parseNumber(): Number | Null

Description

The parseNumber() method converts the calling string to a numeric Number.

  • Leading and trailing whitespace are allowed.

  • Exponential notation is allowed.

  • Comma separators aren’t allowed.

This method attempts to parse the calling string in the following order:

The calling string isn’t changed.

Parameters

None

Return value

One of:

Type Description

Number

Value parsed from the calling string.

Null

Unable to parse calling String.

Math.Infinity

A String indicating a value greater than a Number can hold. A calling String value of Math.Infinity also returns Math.Infinity.

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

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!