The number class has a toString method that accepts base as argument. We can pass base 16(hex numbers) to get the desired number converted to hexadecimal string.
Where, the paramters are the following −
string −The value to parse. If this argument is not a string, then it is converted to one using the ToString method. Leading whitespace in this argument is ignored.
radix −An integer between 2 and 36 that represents the radix (the base in mathematical numeral systems) of the string.
So we can pass the string and the radix and convert any numbner with base from 2 to 36 to integer using this method.
console.log(parseInt("ff", 16)) console.log(parseInt("11", 16))