Skip to content

into()

ts
function into(value): number | null;

Defined in: number/into.ts:16

Converts an arbitrary value into a number using Number(value) internally

Parameters

ParameterTypeDescription
valueunknownvalue that we want to turn into a number

Returns

number | null

null if value is null or undefined. Otherwise, the result of Number(value) (which may be NaN)

Example

ts
console.assert(Number.isNaN(Number.into("abc")) === true);
console.assert(Number.into("5") === 5);
console.assert(Number.into(undefined) === null);
console.assert(Number.into(5n) === 5);

Since

1.0.0

Author

Simon Kovtyk