For AI agents: the complete documentation index is available at https://massaman.dev/llms.txt, the full documentation bundle is available at https://massaman.dev/llms-full.txt, and this page is available as Markdown at https://massaman.dev/reference/conversion/toNumber.md.

toNumber

Converts a value to a number.

Thin wrapper over Number(value) — kept as a stable surface so callers don't depend directly on the global constructor's semantics (which have shifted in the past, e.g. Number(BigInt), and may again).

toNumber('42') // 42
toNumber(null) // 0

Usage

toNumber(value: unknown)

Converts a value to a number.

Thin wrapper over Number(value) — kept as a stable surface so callers don't depend directly on the global constructor's semantics (which have shifted in the past, e.g. Number(BigInt), and may again).

import { toNumber } from 'massaman'
// or:  import { toNumber } from 'massaman/conversion'

toNumber('42') // 42
toNumber(null) // 0

Parameters

valueunknownrequired

the value to convert.

Returns

the input value converted using JavaScript number coercion.

number