For integer we have parseInt, which accepts base as an argument. For bases 2, 8, 10 and 16 we can use some prefix, but for others we forsed to use parseInt:
console.log(parseInt("10", 2), +"0b10")
console.log(parseInt("10", 8), +"0o10")
console.log(parseInt("10", 10), +"10")
console.log(parseInt("10", 14))
console.log(parseInt("10", 16), +"0x10")
console.log(parseInt("10", 36))
Now I'm looking at BigInt
and can't find there anything like that. How can I parse bigint in specific base without writing my own function?
console.log("" + BigInt("0b10"))
console.log("" + BigInt("0o10"))
console.log("" + BigInt("10"))
console.log("" + "base 14?")
console.log("" + BigInt("0x10"))
console.log("" + "base 36?")