🔰module
JS ⟩ module
Modules provide structure to bigger programs by separating the code into pieces with clear interfaces and dependencies.
interface: the part that’s visible from other modules.
dependencies: other modules that it makes use of.
in Node.js, each JS file is treated as a module.
in a module there's no "module scope object" for these top-level declarations to be added to as property.
( 👉 compare: global var / function is global object property❗️)
The relations between modules are called dependencies. When a module needs a piece from another module, it is said to depend on that module.
Last updated