# 📦 Modules

2 min read, 212 words es2015modulesjavascriptimportexport
  • 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";

source (opens new window)

# ⭐️ Main Features

  1. Arrows and Lexical this
  2. Classes
  3. Templated strings
  4. Object/Array Destructuring
    1. fail-soft
  5. Default + Rest + Spread
  6. Let + Const
  7. for ... of Iterator
  8. Generators function* and yield
  9. Modules export/import
  10. Promises - asynchronous programming

# 🌎 Resources

Subscribe to our Newsletter

If you like my work and think it was helpful kindly support my work


Buy Me A Coffee