formatBase

Formats a number as a string in the specified base.

formatBase

Formats a number as a string in the specified base.

Type: transform

Parameters

  • input (unknown): The input number to format.
  • base (number): The numeric base to convert to (2-36).

Returns

Type: string

The number formatted in the specified base, or empty string if input cannot be converted to a number.

Examples

formatBase(255, 16) // "ff"
(10)|formatBase(2) // "1010"
formatBase(64, 8) // "100"
Cookie Notice

We use cookies to enhance your browsing experience.