ES modules and CommonJS—differences and interoperability
Let’s now discuss some important differences between ES modules and CommonJS and how the two module systems can work together when necessary.
Strict mode
As opposed to CommonJS, ES modules run implicitly in strict mode. This means that we don’t have to explicitly add the 'use strict' statements at the beginning of every file. Strict mode cannot be disabled; therefore, we cannot use undeclared variables or the with statement or have other features that are only available in non-strict mode. However, this is definitely a good thing, as strict mode is a safer execution mode.
If you are curious to find out more about the differences between the two modes, you can check out a very detailed article on MDN Web Docs (nodejsdp.link/strict-mode).
Top-level await
Top-level await allows developers to use await at the top level of a module, simplifying asynchronous code without...