Global keyword
The global keyword is used to define global variables. Global variables are the only way to define a mutable variable outside of the scope of a function. Global variables are also used for importing external data which can be provided while the Wasm module is being instantiated.
Example
This example imports the `window.setInterval` function from Javascript to run a function every second which repeatedly increments the global variable.
Note
This website has no way of clearing the setInterval when a new module is recompiled, so you will need to refresh the page if you make any edits. Make sure to copy your code before you refresh though :)Global variables can also be more complicated types like being multivalued, GC heap types, arrays, etc.