> For the complete documentation index, see [llms.txt](https://augustus-pash.gitbook.io/wasm/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://augustus-pash.gitbook.io/wasm/types/functions.md).

# Functions

### Function

```javascript
(func $add11 (param $p i32) (result i32) 
// name of func, paramter, return value (returns the last value on the stack)
    get_local $p
    i32.const 11
    i32.add)

// call function with param of 4
i32.const 4
call $add11
```

### Function Export Example

```javascript
(func (export "add11") (param $p i32) (result i32)
    get_local $p
    i32.const 11
    i32.add)
```

```javascript
WebAssembly.instantiate(wasmModule.toBinary({}).buffer, importObject).then(function(res) {
    console.log(res.instance.exports.add11(2));
  });
```

### Function Import Example

```javascript
function consoleLogString(offset, length) {
    var bytes = new Uint8Array(memory.buffer, offset, length);
    var string = new TextDecoder('utf8').decode(bytes);
    console.log(string);
}


var importObject = { console: { log: consoleLogString } };

WebAssembly.instantiate(wasmModule.toBinary({}).buffer, importObject).then(function(res) {
    
  });
```

```javascript
// import
(import "console" "log" (func $log (param i32 i32)))

// call
i32.const 0 // param 1
i32.const 1 // param 2
call $log
```
