I am adapting a very simple example of Webassembly used in Javascript. I encountered a problem I do not understand.
When I try to change the name of the variable “instance” to “instance1” below, the (firefox) browser’s developer console produces an error message that instance1 is undefined (when I try to refer to instance1 in the next statement in my javascript code.)
This would become a problem when I am working with two different Webassembly functions (and associated supporting data structures) in the same Javascript code, because the name instance is duplicated (I don’t want to use Javascript Immediately-invoked Function Expression in this case, as I want the variables “instance1” and “instance2” to be globally visible in other areas of my Javascript code.
THIS IS FROM THE EXAMPLE I AM WORKING WITH, AND THIS WORKS:
// Make the class into an object, using the log function and memory space previously assigned
const { instance } = await WebAssembly.instantiate(bytes1, {
env: { log1, mem1 }
});
THIS IS MODIFIED TO USE instance1 INSTEAD OF instance AND DOES NOT WORK (instance1 is undefined the first time it is then referenced in the subsequent Javascript statements)
// Make the class into an object, using the log function and memory space previously assigned
const { instance1 } = await WebAssembly.instantiate(bytes1, {
env: { log1, mem1 }
});
Thanks for any advice or request for further clarification of my problem statement!
Dave