Converts a number to an abbreviated string format with suffixes like 'k', 'm', 'b', etc.
The number to abbreviate
Configuration options
Number of decimal places to display (default: 1)
Whether to display trailing zeros (default: true)
The abbreviated number as a string
toAbbreviated(1500) // "1.5k"toAbbreviated(2500000) // "2.5m"toAbbreviated(1000000, {decimals: 2, trim: true}) // "1m"toAbbreviated(1000000, {decimals: 2, trim: false}) // "1.00m"toAbbreviated(1234567, {decimals: 0}) // "1m"toAbbreviated(500) // "500"toAbbreviated(-3400) // "-3.4k" Copy
toAbbreviated(1500) // "1.5k"toAbbreviated(2500000) // "2.5m"toAbbreviated(1000000, {decimals: 2, trim: true}) // "1m"toAbbreviated(1000000, {decimals: 2, trim: false}) // "1.00m"toAbbreviated(1234567, {decimals: 0}) // "1m"toAbbreviated(500) // "500"toAbbreviated(-3400) // "-3.4k"
Converts a number to an abbreviated string format with suffixes like 'k', 'm', 'b', etc.