All of this value conversion is a lot of mental overhead. Fortunately we can utilize JavaScript to make our lives easier.
Object.prototype.toString(radix)toString() returns a string representation of an object. It takes an optional radix parameter.
radix is the number of unique digits. It is also known as base
| Radix/Base | Type |
|---|---|
| 2 | binary |
| 10 | decimal |
| 16 | hexadecimal |
function hexToDecimal(hex) {
return (hex).toString(10);
}function decimalToBinary(num) {
return (num).toString(2);
}