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 set() prototype method of the WebAssembly.Table object mutates a reference stored at a given index to a different value.
The index of the function reference you want to mutate.
valueThe value you want to mutate the reference to. This must be a value of the table's element type. Depending on the type, it may be an exported WebAssembly function, a JavaScript wrapper for an underlying Wasm function, or a host reference.
None (undefined).
The following example (see table2.html source code and live version) creates a new WebAssembly Table instance with an initial size of two references. We then print out the table length and contents of the two indexes (retrieved via Table.prototype.get()) to show that the length is two, and the indexes currently contain no function references (they currently return null).
We then create an import object that contains a reference to the table:
Finally, we load and instantiate a Wasm module (table2.wasm) using WebAssembly.instantiateStreaming(), print the table length, and invoke the two referenced functions that are now stored in the table. The table2.wasm module adds two function references to the table, both of which print out a simple value (see text representation:
Note how you've got to include a second function invocation operator at the end of the accessor to actually invoke the referenced function and log the value stored inside it (e.g., get(0)() rather than get(0)).
This example shows that we're creating and accessing the table from JavaScript, but the same table is visible and callable inside the Wasm instance, too.
| WebAssembly JavaScript Interface # dom-table-set |
Enable JavaScript to view this browser compatibility table.
This page was last modified on Apr 22, 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.