Skip to content

Type Number

The type::number function converts a value to a number. If the input can be interpreted as a numeric value (e.g., a string representation of a number), it returns the corresponding number. Otherwise, it returns an error.

Syntax

type::number(<value>)

Parameters

  • value: The input value to convert to a number.

Returns

  • Number: The converted numeric value if successful.

Example

Try it out below!
type::number("42")

This function is useful for ensuring that values are numeric before performing mathematical operations or comparisons.