Generated by GPT-5-mini| ArrayBuffer | |
|---|---|
| Name | ArrayBuffer |
| Type | Binary data buffer |
| Introduced | ECMAScript 2015 |
| Specification | ECMAScript |
| File format | Binary |
ArrayBuffer ArrayBuffer is a low-level binary data container in the ECMAScript family used to represent a generic, fixed-length raw binary buffer. It provides the foundation for typed binary access patterns used across Node.js, Chromium, Mozilla Firefox, WebKit and other ECMAScript-compliant engines, and it interoperates with APIs in HTML5, WebRTC, WebGL and IndexedDB. Implementations and usage of ArrayBuffer are shaped by standards and organizations such as TC39, ECMA International, and browser vendors including Microsoft and Apple.
ArrayBuffer defines a contiguous block of memory of a given byte length that can be shared among multiple views and APIs such as Canvas API, Fetch API, WebSockets and Service Worker. It is specified in ECMA-262 and commonly used alongside typed array classes standardized by ECMA International and advanced JavaScript runtimes like V8 and SpiderMonkey. ArrayBuffer itself is immutable in length once created, enabling predictable allocations for engines developed by teams at Google, Mozilla Foundation, and Microsoft Corporation.
ArrayBuffer instances are created using the ArrayBuffer constructor (new ArrayBuffer(byteLength)), a pattern established in the ECMAScript specifications ratified by ECMA International and influenced by proposals discussed in TC39 meetings chaired by representatives from organizations like Google LLC and Microsoft Research. Typical creation patterns are used in server projects running on Node.js and client applications in browsers such as Firefox and Safari where ArrayBuffer may be allocated from Web APIs like WebAssembly memory imports or returned by fetch responses handled via Streams API. Runtime implementers in projects such as V8 and ChakraCore optimize allocation paths for frequent use in libraries like TensorFlow.js and three.js.
Typed arrays (e.g., Int8Array, Uint16Array, Float32Array) and DataView provide different views over an ArrayBuffer, a design influenced by binary manipulation libraries in languages used by Mozilla Foundation and Google engineers. Typed arrays are frequently used in graphics stacks such as WebGL and OpenGL ES bindings, game engines like Unity when targeting WebGL builds, and multimedia frameworks including FFmpeg via emscripten outputs. DataView offers endian-aware getters and setters useful in protocols and formats specified by organizations like IETF, W3C and in file formats authored by projects such as PNG and JPEG toolchains. These APIs enable interoperation with frameworks like WebRTC for real-time media and WebAudio API for audio processing.
ArrayBuffer exposes properties and methods standardized by ECMA International and implemented in engines including V8 and SpiderMonkey: byteLength (read-only), slice(start, end) returning a new ArrayBuffer, and transfer semantics used by postMessage in Web Workers influenced by HTML Living Standard discussions. Typed array and DataView prototypes add methods like set, subarray and getUint32 which are referenced in documentation published by WHATWG and educational resources produced by institutions such as Mozilla Developer Network and W3C. Browser vendors such as Apple and Microsoft have extended and optimized these interfaces to interoperate with platform subsystems like Metal and Direct3D through bindings in graphics layers.
Memory behavior for ArrayBuffer is influenced by garbage collectors in runtimes like V8, SpiderMonkey, and JavaScriptCore, and by low-level memory models developed in projects such as WebAssembly and LLVM. Performance considerations include allocation cost, contiguous memory locality exploited by SIMD optimizations and JIT engines maintained by organizations like Google and Mozilla Foundation. Cross-thread transfer via structured cloning and transferables in postMessage avoids copying by transferring ownership, an approach standardized by HTML Living Standard contributors including engineers from Google LLC and Mozilla Foundation. Engine teams publishing performance guidance often reference benchmarks used by JetStream and Octane.
ArrayBuffer is central to use cases spanning streaming media via Media Source Extensions, 3D rendering in WebGL and WebGPU prototypes influenced by Khronos Group, binary storage in IndexedDB, and native interoperability through WebAssembly modules compiled by Emscripten or LLVM toolchains. It is used in networking layers within WebRTC and WebSocket implementations maintained by browser vendors, in machine learning projects like TensorFlow.js and in cryptographic APIs standardized by groups such as IETF and implemented in OpenSSL-backed servers. ArrayBuffer's cross-platform compatibility is reinforced by collaboration between standards bodies (W3C, ECMA International, IETF) and major implementers including Google, Mozilla Foundation, Apple Inc. and Microsoft Corporation.