toNumber

[ Function ]

public static toNumber(
    value: any,
    defaultValue: number | null = null
): number | null;

Converts any compatible value to a number.

Parameter

Name

Type

Description

value

any

The value to convert.

defaultValue

number, null

This value is returned if the first parameter cannot be converted. Null applies if this parameter is not passed.

Return value

Type

Description

number, null

Returns the appropriate numerical value or null in the event of an error.

toNumber 1:

Available from 1.8