Skip to content

toThousands

Format number with thousands separators.

Usage

js
import { toThousands } from 'js-cool'

Signature

typescript
function toThousands(num: number | string): string

Parameters

ParameterTypeDescription
numnumber | stringNumber to format

Returns

string - Formatted string.

Examples

js
toThousands(1234567) // '1,234,567'
toThousands('1234567.89') // '1,234,567.89'
toThousands(100) // '100'

Released under the MIT License.