Js parseInt type conversion problem

topic description

Why is the output of parseInt ("12 percent, 2) 1?

thought
the binary number 12 does not exist. Shouldn"t the result be NaN?

related codes

console.log(parseInt("12", 2)); // 1
Mar.08,2022

parseInt tries to match and convert until it encounters characters that cannot be converted. So in your example, it matches and converts the character 1, while 2 is ignored

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e51515-43ddc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e51515-43ddc.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?