javascript-questions icon indicating copy to clipboard operation
javascript-questions copied to clipboard

57 - is wrong answer

Open mg901 opened this issue 11 months ago • 2 comments

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 avatar Mar 17 '24 16:03 mg901

@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:

immagine

alexandercerutti avatar Mar 17 '24 20:03 alexandercerutti

In browser environment I get "Assignment to constant variable", not 11. The point is reassign imported variable and then make changes

tsotneforester avatar Mar 22 '24 06:03 tsotneforester