I am converting hex to hex strings then came across 2 ways to do it using the toString()
method:
toString('hex')
toString(16)
I see a lot of resources online also use toString('hex') but when I tried to use it, it gives out an error message: RangeError: toString() radix argument must be between 2 and 36
.
The toString(16)
works perfect.
But just for curiousity, what is the story behind this? Is the toString('hex')
deprecated of some sort? Or is there any specific use-case when that is used instead of toString(16)
Example:
let num = 0x7
console.log('Convert using toSting(hex): ' + num.toString('hex')) // throws an error
console.log('Convert using toSting(16): ' + num.toString(16))