> ## Documentation Index
> Fetch the complete documentation index at: https://bun.ll1025.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 将 Uint8Array 转换为 ArrayBuffer

[`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) 是一种\_类型化数组\_，是对底层 `ArrayBuffer` 中数据的视图。`buffer` 属性返回该 `ArrayBuffer`。

```ts theme={null}
const arr = new Uint8Array(64);
arr.buffer; // => ArrayBuffer(64)
```

***

`Uint8Array` 可能只是底层 `ArrayBuffer` 中数据\_子集\_的视图。在这种情况下，`buffer` 属性返回整个缓冲区，而 `byteOffset` 和 `byteLength` 属性指示该子集。

```ts theme={null}
const arr = new Uint8Array(new ArrayBuffer(64), 16, 32);
arr.buffer; // => ArrayBuffer(64)
arr.byteOffset; // => 16
arr.byteLength; // => 32
```

***

参见 [二进制数据](/runtime/binary-data#conversion)。
