JavaScript modules:

- What are JavaScript modules?
Modules
- encapsulate code
- control access
- reference its own dependencies internally
- extract hardcoded constants to get rid of unnecessary duplication which can lead to bugs.
import
export
rename
export { getSessions as sessions }
import sessions from ....
default: to simplify exports, without having to expose variables
export default function getSessions() {
}
OR
export { getSessions as default, sessionUrl };
- when compared to the constructor design pattern, generally there is only one of the module object like a service.
- What are the benefits of using JavaScript modules?
- How do you create a JavaScript module?
- What is the difference between named and default exports in a JavaScript module?
- How do you import a JavaScript module in another file?
- What is the difference between a relative and an absolute path when importing a JavaScript module?
- How do you use a JavaScript module in an HTML file?
- What are the different types of JavaScript module formats?
- What is the purpose of the "use strict" directive in a JavaScript module?
- What is the ES6 module loader API and how does it work?