A WebAssembly.Instance
object is a stateful, executable instance of a WebAssembly.Module. Instance
objects contain all the Exported WebAssembly functions that allow calling into WebAssembly code from JavaScript.
The WebAssembly.Instance()
constructor function can be called to synchronously instantiate a given WebAssembly.Module
object. However, the primary way to get an Instance
is through the asynchronous WebAssembly.instantiateStreaming()
function.
Important: Since instantiation for large modules can be expensive, developers should only use the Instance()
constructor when synchronous instantiation is absolutely required; the asynchronous WebAssembly.instantiateStreaming()
method should be used at all other times.
var myInstance = new WebAssembly.Instance(module, importObject);
WebAssembly.Module
object to be instantiated.Instance
, such as functions or WebAssembly.Memory
objects. There must be one matching property for each declared import of module
or else a WebAssembly.LinkError is thrown.Instance
instancesAll Instance
instances inherit from the Instance()
constructor's prototype object — this can be modified to affect all Instance
instances.
Instance.prototype.constructor
WebAssembly.Instance()
constructor.Instance.prototype.exports
Read only
None.
Specification | Status | Comment |
---|---|---|
WebAssembly JavaScript Interface The definition of 'Instance' in that specification. | Working Draft | Initial draft definition. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 57 | 16 | 52
|
No | 44 | 11 |
exports |
57 | 16 | 52
|
No | 44 | 11 |
prototype |
57 | 16 | 52
|
No | 44 | 11 |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | 57 | 57 | Yes
|
52
|
? | 11 | 7.0 |
exports |
57 | 57 | Yes
|
52
|
? | 11 | 7.0 |
prototype |
57 | 57 | Yes
|
52
|
? | 11 | 7.0 |
Server | |
---|---|
Node.js | |
Basic support | 8.0.0 |
exports |
8.0.0 |
prototype |
8.0.0 |
© 2005–2018 Mozilla Developer Network and individual 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/WebAssembly/Instance