By the end of this lesson, you will:
ES6+ refers to versions of JavaScript released after ECMAScript 6 (2015) — including ES7, ES8, and beyond.
These modern features help you:
✅ Write less code
✅ Make code easier to read and maintain
✅ Work seamlessly with tools like React
let and const (Block Scoping)let count = 5; // can be reassigned
const name = "Sam"; // cannot be reassigned
✅ let replaces var for mutable values
✅ const is used for values that shouldn’t change
// Traditional
function greet(name) {
return "Hello " + name;
}
// Arrow
const greet = (name) => `Hello ${name}`;
✅ Shorter syntax
✅ Automatically binds this in many cases (important in React)
const name = "Taylor";
const greeting = `Welcome back, ${name}!`;
✅ Use backticks (`)
✅ Embed expressions with ${}
✅ Great for building dynamic UIs
const user = { name: "Luna", age: 25 };
const { name, age } = user;
console.log(name); // "Luna"
✅ Pulls properties directly from arrays/objects
✅ Cleaner access to props/state in React
function sayHi(name = "Guest") {
console.log(`Hi, ${name}`);
}
✅ Sets fallback values for function arguments
...)// Spread
const arr1 = [1, 2];
const arr2 = [...arr1, 3, 4]; // [1, 2, 3, 4]
// Rest
function sum(...nums) {
return nums.reduce((a, b) => a + b);
}
✅ Spread: Copy or combine arrays/objects
✅ Rest: Handle multiple function arguments
map, filter, findconst nums = [1, 2, 3, 4];
const doubled = nums.map(n => n * 2); // [2, 4, 6, 8]
✅ Essential for rendering lists in React (.map)
✅ Modern, functional way to handle arrays
var user = {
name: "Zoe",
age: 30
};
function greet(user) {
return "Hello, " + user.name;
}
const user = {
name: "Zoe",
age: 30
};
const greet = ({ name }) => `Hello, ${name}`;
Take a few traditional functions and rewrite them using arrow syntax.
Create an object and write a function that pulls out specific values using object destructuring.
| Feature | Use Case |
|---|---|
let/const |
Safer, scoped variables |
| Arrow functions | Cleaner syntax, auto-binding this |
| Template literals | Easy string formatting |
| Destructuring | Extract data from objects/arrays |
| Spread / Rest | Clone, merge, or handle multiple values |
map, filter |
Functional array handling |
let vs const?Refactor a basic to-do app or calculator using:
const, let.map() to display a list
Not a member yet? Register now
Are you a member? Login now