What is ES6?
ES6 (ECMAScript 2015) massively upgraded JavaScript. It added cleaner syntax, new concepts, and made JavaScript more powerful and readable.
1. let and const
Better variable declarations.
let x = 10;
const y = 20;
2. Arrow Functions
const add = (a, b) => a + b;
console.log(add(5, 3));
3. Template Literals
const name = "Kaloyan";
console.log(`Hello, ${name}!`);
4. Default Parameters
function greet(name = "Guest") {
console.log("Hello " + name);
}
5. Spread Operator (...)
const nums = [1, 2, 3];
const more = [...nums, 4, 5];
6. Rest Parameters
function sum(...values) {
return values.reduce((a, b) => a + b);
}
7. Destructuring
const person = { name: "Kaloyan", age: 12 };
const { name, age } = person;
8. Classes
class Car {
constructor(model) {
this.model = model;
}
}
const c = new Car("Subaru");
9. Promises
const delay = ms => new Promise(res => setTimeout(res, ms));
delay(1000).then(() => console.log("Done!"));
10. Modules (import/export)
// export
export const pi = 3.14;
// import
import { pi } from "./math.js";
What's Next?
You now know the most important ES6 features — next you’ll use them inside real modern JavaScript workflows and APIs.