1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-28 21:32:20 +00:00

docs(string-methods): edit

This commit is contained in:
ruanyf 2019-05-26 20:41:20 +08:00
parent 424d5e45af
commit 0a5db0d02a

View File

@ -123,16 +123,17 @@ for (let ch of s) {
// 61 // 61
``` ```
或者使用 `Spread` 展开运算 另一种方法也可以,使用扩展运算符(`...`)进行展开运算。
```javascript ```javascript
let arr = [...'𠮷a']; // arr.length === 2 let arr = [...'𠮷a']; // arr.length === 2
arr.forEach(ch => console.log(ch.codePointAt(0).toString(16))); arr.forEach(
ch => console.log(ch.codePointAt(0).toString(16))
);
// 20bb7 // 20bb7
// 61 // 61
``` ```
`codePointAt()`方法是测试一个字符由两个字节还是由四个字节组成的最简单方法。 `codePointAt()`方法是测试一个字符由两个字节还是由四个字节组成的最简单方法。
```javascript ```javascript