46   JS

var ten_num=18;
var two_str='0b10010';
var eight_str='0o22';
var sixteen_str='0x12';

// 转换成 10 进制
console.log(Number(ten_num));
console.log(Number(two_str));
console.log(Number(ten_num));
console.log(Number(eight_str));
console.log(Number(sixteen_str));

// 10 进制转换成其他进制
console.log(Number(two_str));
console.log(Number(ten_num).toString(2));
console.log(Number(eight_str).toString(8));
console.log(Number(sixteen_str).toString(16));



Leave a Reply

Your email address will not be published. Required fields are marked *