JS Built-ins
NumberparseIntintermediate

Number.parseInt() β€” hex string with radix 16

πŸ“– Usage Example
// Parse a string to an integer with optional base
Number.parseInt('42px')       // β†’ 42
Number.parseInt('0xff', 16)   // β†’ 255
Number.parseInt('10', 2)      // β†’ 2

Use Number.parseInt() to convert a string to an integer, optionally specifying a radix for binary, octal, or hexadecimal input.

Number.parseInt() β€” Hex

Use radix 16 to parse hexadecimal strings.

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