Lesson 21. Using modules

After reading lesson 21, you will

  • Understand how to specify the location of a module you intend to use
  • Understand all the various ways of importing values from modules
  • Understand how to import modules for side effects
  • Understand the order of execution of code when importing modules
  • Be able to break apart large modules into smaller ones

Modules are a great way to separate your logic into cohesive units and share logic across files without the cumbersome use of global variables. They also allow you to import only what is needed, keeping the cognitive load down and making maintenance easier. In the previous lesson you learned what a module is and the basics of how to create a module and export values. In this lesson ...

Get Get Programming with JavaScript Next now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.