Modern JavaScript (ES6 and beyond) introduced powerful new features that make code cleaner, faster, and easier to maintain.
This lesson covers the most essential ES6+ features you will use every day.
1. let and const
Modern replacements for var.
let age = 30;
const name = "Emre";- let can be reassigned
- const cannot be reassigned
2. Template Literals
Use backticks to embed variables inside strings.
let city = "Antalya";
let msg = `Hello from ${city}`;Supports multi-line strings:
let text = `
Line 1
Line 2
`;3. Destructuring
Extract values from arrays or objects easily.
Object destructuring
const user = {
name: "Emre",
age: 30,
};
const { name, age } = user;Array destructuring
const colors = ["red", "green", "blue"];
const [first, second] = colors;4. Spread Operator
Used for copying or merging arrays and objects.
Copy an array
const arr = [1, 2, 3];
const copy = [...arr];Merge arrays
const merged = [...arr, 4, 5];Copy an object
const cloned = { ...user };5. Arrow Functions
Shorter and more modern function syntax.
const greet = () => console.log("Hello");With parameters:
const add = (a, b) => a + b;6. Default Parameters
function welcome(name = "Guest") {
console.log("Hello, " + name);
}7. Classes (OOP in JS)
class Person {
constructor(name, age) {
this.name = name;
this.age = age;
}
greet() {
console.log("Hello I'm " + this.name);
}
}
const p = new Person("Emre", 30);
p.greet();8. Modules (import / export)
Used to split code into reusable files.
Export
export const PI = 3.14;Import
import { PI } from "./math.js";Modules help organize large codebases.
Summary
In this lesson, you learned:
- let and const
- Template literals
- Destructuring
- Spread operator
- Arrow functions
- Default parameters
- Classes
- Modules
With this final lesson, your JavaScript Beginners Course is complete. You are now ready to build interactive web applications and continue with more advanced JS topics!