JavaScriptIntermediate

ES6+ Modern JavaScript

Explore modern JavaScript features including modules, spread/rest, optional chaining, and template literals.

4 hours
5 key concepts
2 in-depth sections
Official Docs

0 of 5 concepts completed (0%)

What You'll Learn

1.Destructuring, Spread & Rest

javascript
// Object destructuring with rename and defaults

// Array destructuring with skip const [first, , third, ...rest] = [1, 2, 3, 4, 5];

// Function parameter destructuring function displayUser({ name, role = "user", avatar = "/default.png" }) { return ${name} (${role}); }

// Spread clone, merge, convert const merged = { ...defaultConfig, ...userConfig }; const withNew = { ...existing, updatedAt: new Date() }; const copy = [...original]; const args = [...arguments]; // convert Arguments to Array

Math.max(...[1, 2, 3]); // 3

// Rest collect remaining arguments function sum(first, ...others) { return others.reduce((a, b) => a + b, first); }

// Dynamic imports (code splitting) const { formatDate } = await import("./utils/date.js");

// Template literal with expression const html =

${title.toUpperCase()}

${items.length} items

; ```

2.Map, Set & Symbols

javascript
// Map ordered key-value pairs, any type as key
const cache = new Map();
cache.set("user:42", { name: "Sufi" });

cache.get("user:42"); // { name: 'Sufi' } cache.has("user:42"); // true cache.size; // 2 cache.delete("user:42");

// Iterate Map for (const [key, value] of cache) { console.log(key, value); }

// Map from array of pairs const roles = new Map([ ["admin", ["read", "write", "delete"]], ["user", ["read"]], ]);

// Set unique values only const seen = new Set([1, 2, 2, 3, 3, 3]); console.log([...seen]); // [1, 2, 3]

// Remove duplicates from array const unique = [...new Set(array)];

// Set operations const a = new Set([1, 2, 3]); const b = new Set([2, 3, 4]); const union = new Set([...a, ...b]); // {1,2,3,4} const intersection = new Set([...a].filter(x => b.has(x))); // {2,3} const difference = new Set([...a].filter(x => !b.has(x))); // {1}

// Symbol guaranteed unique const ID = Symbol("id"); const obj = { [ID]: 42, name: "test" }; obj[ID]; // 42 Object.keys(obj); // ["name"] Symbol not enumerable ```

Code Example

// Optional chaining
const city = user?.address?.city ?? "Unknown";

// Spread operator
const merged = { ...defaults, ...userPrefs };
const arr = [...existing, newItem];

// ES Modules
export const add = (a, b) => a + b;
import { add } from "./math.js";

// Map and Set
const map = new Map();
map.set("key", "value");

const set = new Set([1, 2, 2, 3]);
console.log([...set]); // [1, 2, 3]

Pro Tips

  • 1Optional chaining (?.) and nullish coalescing (??) together eliminate 90% of defensive null-checking boilerplate.
  • 2ES modules are static imports are resolved at parse time. This enables tree-shaking: bundlers can drop unused exports automatically.
  • 3Symbol guarantees a unique value perfect for non-string object keys and avoiding third-party code collisions.
  • 4WeakMap and WeakSet hold weak references when the key object is garbage collected, the entry disappears. Useful for private data on DOM nodes.

Topics Covered

ES6ModulesModern JS

Continue Learning

Explore the official documentation and deepen your knowledge with real-world practice.

Explore the Full Portfolio

This is the complete portfolio of Sufi Khan Sulaiman, a technology leader specialising in B2B commerce and digital automation. Start from the Home page for the overview, then move through two decades of career experience across FLIR Systems, Lorex Technology, and 1c Platform, and the full catalogue of project case studies spanning headless commerce migrations, AI recommendation engines, and multi-channel fulfilment systems.

The skills and certifications page maps the technical and leadership capabilities behind the work, while the articles and the knowledge base break down the thinking into actionable frameworks. For hands-on learning, the tutorials and applications sections cover practical builds from front-end fundamentals to full-stack web apps.

For consulting engagement, the expertise page outlines service offerings, the ecommerce hub covers platform architecture and automation strategy, and the ecommerce guide (PDF) is a downloadable 55-page field manual. When you are ready to talk, the contact page is the direct line.