const memory = new WebAssembly.Memory({
initial: 10,
maximum: 100,
});WebAssembly.Memory / notebook
WebAssembly.Memory
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
const memory = new WebAssembly.Memory({
initial: 10,
maximum: 100,
});
WebAssembly.instantiateStreaming(fetch("memory.wasm"), {
js: { mem: memory },
}).then((obj) => {
const summands = new DataView(memory.buffer);
for (let i = 0; i < 10; i++) {
summands.setUint32(i * 4, i, true); // WebAssembly is little endian
}
const sum = obj.instance.exports.accumulate(0, 10);
console.log(sum);
});WebAssembly.instantiateStreaming(fetch("memory.wasm")).then((obj) => {
const values = new DataView(obj.instance.exports.memory.buffer);
console.log(values.getUint32(0, true));
});const memory = new WebAssembly.Memory({
initial: 10,
maximum: 100,
shared: true,
});const memory = new WebAssembly.Memory({
address: "i64",
initial: 1n,
maximum: 10n,
});