Uint8Array
is a typed array in JavaScript designed for handling raw binary data efficiently. Buffer
is a subclass of Uint8Array that's only available in Node. js
Feature | Uint8Array |
Buffer (Node.js) |
---|---|---|
Environment | Browser and Node.js | Node.js only |
Inheritance | TypedArray | Subclass of Uint8Array |
Methods | Basic array methods | Additional methods (e.g., toString , from ) |
Encoding Support | No encoding support | Supports hex, utf-8, base64, etc. |
Performance | Efficient for general binary data | Optimized for Node.js operations |