Modules
Prerequisites: Functions
A module is a single file whose functions and variables you can reuse
in another file, via export/import.
// math.js
export function add(a, b) {
return a + b;
}
// main.js
import { add } from "./math.js";
console.log(add(2, 3));
This is the modern "ES module" syntax; older Node code (and many
tutorials) instead use require()/module.exports ("CommonJS") —
both still exist in the ecosystem, but ES modules are the current
standard.