The example in this article describes the implementation method of simple hexadecimal conversion in JavaScript. Share it with everyone for your reference, the details are as follows:
Base conversion under JavaScript is very convenient. The system has provided built-in methods to provide conversion between 2 and 36 bases. The representations directly provided include octal, decimal, and hexadecimal.
var w=function(s){document.write('<br>'+s)}; //十进制转其他 var x=110; w(x); w(x.toString(8)); w(x.toString(32)); w(x.toString(16)); //其他转十进制 var x='110'; w(parseInt(x,2)); w(parseInt(x,8)); w(parseInt(x,16)); //其他转其他 //先用parseInt转成十进制再用toString转到目标进制