彻底搞懂字符编码( 三 )

2.)ECMAScript 6版本 增强了对Unicode的支持,基本解决了这个问题 。
let s = '12';let output = [];for(let s of string ){output.push(s)}console.log(output) //["", "1", "2"]Array.from(string).length4.javascript字符串和码点之间的转换方法?

  • String.fromCodePoint():从Unicode码点返回对应字符
console.log(String.fromCodePoint(9731, 9733, 9842, 0x2F804));// expected output: "?


推荐阅读