可以使用 toString() 方法将字符串转换为16进制,然后使用 parseInt() 方法将其转换回10进制。例如:

let str = "hello";
let hex = str.toString(16); // "68656c6c6f"
let dec = parseInt(hex, 16); // 448378203247

其中,toString(16) 将字符串转换为16进制,parseInt(hex, 16) 将16进制转换为10进制。

JS 字符串转换16进制

原文地址: https://www.cveoy.top/t/topic/hdLr 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录