Will es6 scripts outside of export be exported?

I import a print.js file in index.js. In this print.js, I also console.log in addition to export.
then print it out and find that there is 2222 in the browser console. Why is this

?
Mar.09,2021

is very simple, when import, the module code that is import will be executed once.


only the value of export will be imported
, but the global code of the imported module will be executed

refer to import


console has its output location, not in your import file output

Menu