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

toInteger

Converts a value to an integer by calling toNumber and truncating.

toInteger('4.9') // 4
toInteger(null) // 0

Usage

toInteger(value: unknown)

Converts a value to an integer by calling toNumber and truncating.

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

toInteger('4.9') // 4
toInteger(null) // 0

Parameters

valueunknownrequired

the value to convert.

Returns

the converted number truncated toward zero.

number