WebAssembly.Table.prototype.grow()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2017.

The grow() prototype method of the WebAssembly.Table object increases the size of the Table instance by a specified number of elements, filled with the provided value.

Syntax

js
grow(delta)
grow(delta, value)

Parameters

delta

The number of elements you want to grow the table by.

value Optional

The element to fill the newly-allocated space with.

Return value

The previous length of the table.

Exceptions

RangeError

Thrown in one of the following cases:

  • If the current size added with delta exceeds the Table instance's maximum size capacity.
  • If the client doesn't have enough memory for the allocation.
TypeError

Thrown if value is not a value of the element type of the table.

Examples

Using grow

The following example creates a new WebAssembly Table instance with an initial size of 2 and a maximum size of 10:

js
const table = new WebAssembly.Table({
  element: "anyfunc",
  initial: 2,
  maximum: 10,
});

Grow the table by 1 element using Table.grow():

js
console.log(table.length); // 2
table.grow(1);
console.log(table.length); // 3

Using grow with a value

The following example creates a new WebAssembly Table instance with an initial size of 0 and a maximum size of 4, filling it with an object:

js
const myObject = { hello: "world" };

const table = new WebAssembly.Table({
  element: "externref",
  initial: 0,
  maximum: 4,
});

Grow the table by 4 units and fill it with a value using WebAssembly.grow():

js
table.grow(4, myObject);
console.log(myObject === table.get(2)); // true

Specifications

Specification
WebAssembly JavaScript Interface
# dom-table-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
Chrome – Full support
Chrome 57 (Release date: 2017-03-09)
footnote Full support
Edge – Full support
Edge 16 (Release date: 2017-10-17)
footnote Full support
Firefox – Full support
Firefox 52 (Release date: 2017-03-07)
footnote Full support
Opera – Full support
Opera 44 (Release date: 2017-03-21)
footnote Full support
Safari – Full support
Safari 11 (Release date: 2017-09-19)
footnote Full support
Chrome Android – Full support
Chrome Android 57 (Release date: 2017-03-16)
footnote Full support
Firefox for Android – Full support
Firefox for Android 52 (Release date: 2017-03-07)
footnote Full support
Opera Android – Full support
Opera Android 43 (Release date: 2017-09-27)
footnote Full support
Safari on iOS – Full support
Safari on iOS 11 (Release date: 2017-09-19)
footnote Full support
Samsung Internet – Full support
Samsung Internet 7 (Release date: 2018-03-16)
footnote Full support
WebView Android – Full support
WebView Android 57 (Release date: 2017-03-16)
footnote Full support
WebView on iOS – Full support
WebView on iOS 11 (Release date: 2017-09-19)
footnote Full support
Bun – Full support
Bun 1 (Release date: 2023-09-08)
footnote Full support
Deno – Full support
Deno 1 (Release date: 2020-05-13)
footnote Full support
Node.js – Full support
Node.js 8 (Release date: 2017-05-30)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

See also