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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.