1.十进制转换为二进制 var toBin = (n) => { if(n == 0) return '0'; var res = ''; while(n != 0) { res = n % 2 + res n = parseInt(n / 2) } return res; } 2.二进制转换为十进制 var toDecimal = (s) => { var res = 0; var arr = s.split(''); var len = arr.length; for(var i = 0;…