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

docs(arraybuffer): edit ab2str

This commit is contained in:
ruanyf 2017-10-15 16:09:15 +08:00
parent 24e9149543
commit 7680ea586a

View File

@ -452,6 +452,8 @@ Float64Array.BYTES_PER_ELEMENT // 8
```javascript
// ArrayBuffer 转为字符串,参数为 ArrayBuffer 对象
function ab2str(buf) {
// 注意,如果是大型二进制数组,为了避免溢出,
// 必须一个一个字符地转
return String.fromCharCode.apply(null, new Uint16Array(buf));
}