JS Built-ins
GlobalFunctionsparseIntbeginner

parseInt β€” binary radix

πŸ“– Usage Example
parseInt('10', 2)    // β†’ 2   (binary 10 = decimal 2)
parseInt('1010', 2)  // β†’ 10

The second argument is the radix β€” parseInt('10', 2) treats the string as binary.

parseInt with Radix

parseInt('10', 2) parses '10' as binary, returning 2.

Challenge: Verify the binary parse.

πŸ’‘ Hints (1)
  • β€’ The second argument to parseInt is the radix (base). Base 2 means binary.