© Raju Gandhi 2019
R. GandhiJavaScript Nexthttps://doi.org/10.1007/978-1-4842-5394-6_12

12. Namespacing Code Using Modules

Raju Gandhi1 
(1)
Columbus, OH, USA
 

JavaScript’s answer to “packaging” or namespacing can be expressed rather succinctly—it was nonexistent. This has been one of the most glaring omissions in the language design since the beginning, and has led to a variety of attempts at modularizing code. These ranged from homegrown solutions to full-blown specifications like AMD.1

ES6’s answer to this problem is modules. In this chapter we will learn how to create and consume modules using the new support for the same provided in ES6. We will be ready to do away with hacky solutions like IEFEs, and be ready to embrace a consistent, platform ...

Get JavaScript Next: Your Complete Guide to the New Features Introduced in JavaScript, Starting from ES6 to ES9 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.