31: Modules and import

Originally JavaScript had no concept of "modules" because it lived entirely in the browser. A systems language needs to have modules, so Node.JS added modules through the CommonJS system. This uses the require function to load modules, which you've been using this whole time.

In Exercise 13 you wrote a simple module named geometry.js:

{{ ork.js("ex13_geometry.js") }}

This code exposed the area and circumference functions using the module.exports "magic" variable.

Learn JavaScript Today

Register today for the Beginner Basics course and get the new releases by just paying the difference. There's also special discounts for existing customers when new courses are released.

Still Not Sure? Check out more curriculum!