Skip to content

Latest commit

 

History

History
25 lines (16 loc) · 522 Bytes

10_modules.md

File metadata and controls

25 lines (16 loc) · 522 Bytes

Modules and ES6 Imports/Exports

Organizing code into modules

Modules are used to organize code into separate files, each with its own scope and exports.

Exporting and importing modules

You can export and import functionality between modules using the export and import keywords. Example:

Module A

export function greet(name) {
  console.log("Hello, " + name + "!");
}

Module B

import { greet } from "./moduleA.js";

greet("John");  // Output: "Hello, John!"