Modular Programming

Modular programming is one of the most important and frequently used software design techniques. Modular programming basically means splitting your code into multiple files that are usually independent of each other. This makes it a cake-walk when managing and maintaining different modules of a program. It helps in debugging nasty bugs easily, pushing updates to a particular module, and so on.

Unfortunately, for a long time, JavaScript didn't support modules natively; that led programmers to use alternative techniques to achieve modular programming in JavaScript. However, ES6 introduced a native modular technique in JavaScript for the first time.

This chapter is all about how to create and import JavaScript modules. In ...

Get Learn ECMAScript - Second Edition 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.