Get to know MDN better
This feature is well established and works across many devices and browser versions. It’s been available across browsers since October 2017.
The WebAssembly.Table() constructor creates a new Table object of the given size and element type, filled with the provided value.
An object that can contain the following members:
elementA string representing the type of value to be stored in the table. This can have a value of "anyfunc" (functions) or "externref" (host references).
initialThe initial number of elements of the WebAssembly Table.
maximum OptionalThe maximum number of elements the WebAssembly Table is allowed to grow to.
value OptionalThe element to fill the newly-allocated space with.
The following example creates a WebAssembly.Table instance with an initial size of 2 elements. The WebAssembly.Table contents are populated using a WebAssembly module and are accessible from JavaScript. When viewing the live example, open your developer console to display console log messages from the code snippets below.
This example uses the following reference files:
Note: A precompiled WebAssembly binary table2.wasm is available for download.
In table2.html, we create a WebAssembly.Table:
We can retrieve the index contents using Table.prototype.get():
Next, we create an import object that contains the WebAssembly.Table:
Next, we load and instantiate a WebAssembly module. The table2.wasm module defines a table containing two functions. The first function returns 42, and the second returns 83:
We instantiate table2.wasm using the WebAssembly.instantiateStreaming() method:
After instantiating table2.wasm, tbl is updated with the following:
The items at indexes 0 and 1 of the table are now callable Exported WebAssembly Functions. To call them, note that we must add the function invocation operator () after the get() call:
While we are creating and accessing the WebAssembly.Table from JavaScript, the same Table is also visible and callable inside the WebAssembly instance.
The following example creates a new WebAssembly Table instance with 4 elements, full of the same object:
| WebAssembly JavaScript Interface # dom-table-table |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Oct 17, 2025 by MDN contributors.
Your blueprint for a better internet.
Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
Portions of this content are ©1998–2026 by individual mozilla.org contributors. Content available under a Creative Commons license.