Exports and Imports

Learn how to export and import in WebAssembly.

We'll cover the following

A WebAssembly module consists of export and import sections. These sections are responsible for exporting functions out of and importing functions into the WebAssembly module.

Exports

In order to call the functions defined in a WebAssembly module from JavaScript, we need to export the functions from the WebAssembly module. The export section is where we’ll define all the functions that are exported out of the WebAssembly module.

Let’s go back to our classic add.wat example from the previous chapter:

Get hands-on with 1200+ tech skills courses.