The easiest way would be to do
console.log(Array.from('110001').reduce((prev, cur) => prev << 1 | cur));
<< is an operator with a left bit, which is substantially multiplied by two here.
Array.from (if available) is preferred over split . This does not matter in this case, but split fails with surrogate pair characters such as ๐บ, and Array.from will handle them correctly. It can also be written as [...'110001'] , which ends with the same.
Of course you could just say
parseInt('110001', 2)
user663031
source share