javascript-questions
javascript-questions copied to clipboard
57 - is wrong answer
Hi, Lydia. Thank you for your remarkable repo.)
I tried executing the example in a sandbox on Stackblitz.com and discovered the answer C
is wrong. The right answer is B
. You can see it here.
@mg901 as I was suspecting, Stackblitz transpiles your code before executing it. It transpiles by using an implementation of CommonJS require()
.
So, it doesn't actually use ESM modules. To check it, just open the project outside Stackblitz editor: https://js-w9nxee.stackblitz.io/
By opening the devtools, you can see the files.
If you run it on a Node project on local, with "type": "module"
in package.json, the answer C is correct:
In browser environment I get "Assignment to constant variable", not 11. The point is reassign imported variable and then make changes