It's only top level var and function declarations in inline JavaScript that pollute the global object (typically prevented with an IIFE). This doesn't happen in type="module" or ECMAScript modules - those names are "module global" but do not create properties on the global object.
const and let are block scoped so they don't affect the global object.
In modules you can still alter the global object via any name that is bound to it (provided that part isn't read-only). So window['myVariable'] = 'NewValue'; is possible.
Imported names are "module global" but do not create properties on the global object
var
andfunction
declarations in inline JavaScript that pollute the global object (typically prevented with an IIFE). This doesn't happen intype="module"
or ECMAScript modules - those names are "module global" but do not create properties on the global object.const
andlet
are block scoped so they don't affect the global object.window['myVariable'] = 'NewValue';
is possible.