Can I use “a” variable in a global scope after module importing or is it available only in a module scope?
It’s only available inside the module it was declared in.
Will ES6 modules have a similar working principle like this trick: […]
Basically yes.
ES6 has these kinds of scopes, order from “top” to “bottom”:
- Global scope
- Module scope
- Function scope
- Block scope