ES6+ Basics

ES6+ Basics

Modern JavaScript (ES2015 and later) adds features you will see in interviews and real codebases.

let and const

Block-scoped; no hoisting like var. Prefer const; use let when reassigning.

Template literals

Backticks and ${} for interpolation and multi-line strings:

javascript
const s = `Hello, ${name}. Result: ${2 + 2}`;

Spread and rest

Spread for copying or merging:

javascript
const arr2 = [...arr1]; const obj2 = { ...obj1, key: \"new\" };

Rest in function params: function f(a, ...rest) { }.

Shorthand and destructuring

Object shorthand: { name, age } instead of { name: name, age: age }. Destructuring in parameters: function f({ name }) { }.

Modules (ESM)

javascript
// utils.js export function add(a, b) { return a + b; } // main.js import { add } from \"./utils.js\";

In Node use \"type\": \"module\" in package.json or .mjs extension. Bundlers (Webpack, Vite) handle modules for the browser.

You have completed the JavaScript Fundamentals track. Finish this lesson to earn your certificate.