JavaScript/进制:修订间差异
来自康健生活
| 第25行: | 第25行: | ||
var num = 0; | var num = 0; | ||
'4e00'.replace(/(.)(?=[^$])/g, "$1,").split(",").forEach(function(d, i){ | '4e00'.replace(/(.)(?=[^$])/g, "$1,").split(",").forEach(function(d, i){ | ||
d.charCodeAt(1).toString(); // 转为二进制 | //d.charCodeAt(1).toString(); // 转为二进制 | ||
const parseIntD = parseInt(d); | const parseIntD = parseInt(d, 16); | ||
num += parseIntD*Math.pow(16,i); | num += parseIntD*Math.pow(16,('4e00'.length - i - 1)); | ||
})</syntaxhighlight> | })</syntaxhighlight> | ||