javascript数字转16进制(如何把三个数字转为16进制颜色代码?)

nmj2086 / 2024-01-26 / 原文

let num = 255; // 要转换的数字
let hexNum = num.toString(16); // 调用toString()函数并传入参数16表示转换成十六进制
console.log(hexNum); // 输出结果为 "ff"

来源:百度AI

 参考:https://www.php.cn/faq/487736.html