0 of 3 saved

JavaScript5 min read

ES Modules

Read this chapter, write the program on this page, then pass a short check to open the next one.

import and export.

ES Modules

ES modules split code into files. export shares values; import brings them in. Node and modern browsers both support ESM.

  • export const x = 1; / export default ...
  • import { x } from "./mod.js";
  • One responsibility per module keeps MERN apps sane.
const message = "modules-ready";
console.log(message);

After you read this chapter, use Write (when available) and Quiz on this page to lock it in.