5. Modular JavaScript
Learning Objectives
By the end of this chapter, you will be able to:
- Import and export functions and objects in JavaScript for code reusability
- Use JavaScript ES6 classes to reduce code complexity
- Implement object-oriented programming concepts in JavaScript
- Create private variables for an object using encapsulation
- Convert ES6 to generic JavaScript using Babel
- Create and publish an npm package in JavaScript
- Combine modules using composability and strategies to create higher-level modules
In this chapter, we will learn about the importance of reusable code in modern JavaScript and how ES6 has introduced syntax for easily creating and using modules. We will create a JavaScript module that can be imported and used by different endpoints of our API.