Type Conversion & Coercion
What will `parseInt('1010', 2)` return?
parseInt('1010', 2) returns 10. The second parameter to parseInt() specifies the radix (base) of the numeral system to be used. When the radix is 2, parseInt() interprets the string as a binary number. In binary, '1010' represents the decimal number 10 (1×2³ + 0×2² + 1×2¹ + 0×2⁰). This functionality allows parseInt() to parse numbers in different numeral systems. Common bases include 2 (binary), 8 (octal), 10 (decimal), and 16 (hexadecimal). If the radix is not specified, it defaults to 10, except when the string starts with '0x' or '0X' (interpreted as hexadecimal).