Spec-Zone.ru › JavaScript

SharedArrayBuffer.prototype.grow()

Baseline Newly available

This feature works across the latest devices and browser versions. This feature might not work in older devices or browser versions. It's been available across browsers since July 2024.

The grow() method of SharedArrayBuffer instances grows the SharedArrayBuffer to the specified size, in bytes.

Syntax

grow(newLength)

Parameters

newLength
The new length, in bytes, to resize the SharedArrayBuffer to.

Return value

None (undefined).

Exceptions

TypeError
Thrown if the SharedArrayBuffer is not growable.
RangeError
Thrown if newLength is larger than the maxByteLength of the SharedArrayBuffer or smaller than the byteLength.

Description

The grow() method grows a SharedArrayBuffer to the size specified by the newLength parameter, provided that the SharedArrayBuffer is growable and the new size is less than or equal to the maxByteLength of the SharedArrayBuffer. New bytes are initialized to 0.

Examples

Note that these examples cannot be run directly from the console or an arbitrary web page, because SharedArrayBuffer is not defined unless its security requirements are met.

Using grow()

In this example, we create a 8-byte buffer that is growable to a max length of 16 bytes, then check its growable property, growing it if growable returns true:

const buffer = new SharedArrayBuffer(8, { maxByteLength: 16 });

if (buffer.growable) {
  console.log("SAB is growable!");
  buffer.grow(12);
}

Specifications

Specification
ECMAScript® 2027 Language Specification
# sec-sharedarraybuffer.prototype.grow

Browser compatibility

Desktop Mobile Server
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on iOS Samsung Internet WebView Android WebView on iOS Bun Deno Node.js
grow
111
111
128
97
16.4
111
128
75
16.4
22.0
No
16.4
1.0.0
1.33
20.0.0

See also

  • SharedArrayBuffer
  • SharedArrayBuffer.prototype.growable
  • SharedArrayBuffer.prototype.maxByteLength

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer/grow

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API