JS Built-ins
NumbertoStringintermediate

toString() β€” hex with radix 16

πŸ“– Usage Example
// Convert number to string in a given base
(255).toString(16)   // β†’ 'ff'
(255).toString(2)    // β†’ '11111111'
(255).toString(10)   // β†’ '255'

Use toString() with a radix argument to convert a number to its binary, octal, hexadecimal, or other base string representation.

Number.prototype.toString()

num.toString(radix?) converts a number to a string, with an optional radix (base).

(255).toString(16)  // β†’ 'ff'
πŸ’‘ Hints (1)
  • β€’ Hexadecimal (base 16) uses digits 0-9 and letters a-f.