MDN self-hosted library · e01.org

WebAssembly.Memory.prototype.grow()

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

js
const memory = new WebAssembly.Memory({
  initial: 1,
  maximum: 10,
});
js
const bytesPerPage = 64 * 1024;
console.log(memory.buffer.byteLength / bytesPerPage); // "1"
console.log(memory.grow(1)); // "1"
console.log(memory.buffer.byteLength / bytesPerPage); // "2"
js
const memory = new WebAssembly.Memory({
  address: "i64",
  initial: 1n,
  maximum: 10n,
});

console.log(memory.grow(1n)); // 1n