Skip to content

Function: toNumber() ​

toNumber(value): number

Defined in: utils.ts:18

Converts a value to a number, treating commas as decimal separators.

Parameters ​

value ​

unknown

The value to convert.

Returns ​

number

The numeric value, or NaN if the conversion fails.

Example ​

ts
toNumber(12)       // 12
toNumber('3.14')   // 3.14
toNumber('3,14')   // 3.14
toNumber('abc')    // NaN