# 📦 Modules
- Originally JS had no concept of modules and
export
,import
- dark ages of JavaScript
- Starting with ECMAScript 2015 (opens new window), JavaScript has a concept of modules.
- Modules have their own name-spaces, unless they are exported
export = className;
// compiles to CommonJS module export syntax
module.exports = className;
// ES6 modules export
export default varName;
// commonJS module export
module.exports = varName;
Difference b/w module.exports.foo and exports.foo ? (opens new window)
# 🚦 Interface
shape of data
# Modules Systems in JS world?
# 🌩 Good questions
- When should I use curly braces for ES6 import?
- default import vs Named import
// export default 42
import A from "ABC";
// export const A = 42
import { A } from "ABC";
// Default export is actually a named export with name default
import { default as Sample } from "../Sample.js";
# ⭐️ Main Features
- Arrows and Lexical this
- Classes
- Templated strings
- Object/Array Destructuring
- fail-soft
- Default + Rest + Spread
- Let + Const
- for ... of Iterator
- Generators function* and yield
- Modules export/import
- Promises - asynchronous programming