| Feature | Description | Example |
|---|
| let | Block scope variable | let age = 20; |
| const | Constant variable | const PI = 3.14; |
| Arrow Function | Short function syntax | const add = (a,b) => a+b; |
| Template Literals | String interpolation using backticks | `Hello ${name}` |
| Destructuring | Extract values from objects/arrays | const {name} = user; |
| Spread Operator | Copy or merge arrays/objects | [...arr] |
| Rest Operator | Handle multiple function arguments | function sum(...num) |
| Default Parameters | Set default function values | function test(x=1) |
| Classes | Create objects using class syntax | class User{} |
| Modules | Import and export files | import app from './app.js' |
| Promises | Handle asynchronous operations | new Promise() |
| for...of Loop | Loop through array values | for(let value of arr) |
| Map Object | Store key-value pairs | new Map() |
| Set Object | Store unique values | new Set() |
| Symbol | Create unique identifiers | Symbol("id") |
1. let Example
let name = "John";
console.log(name);
2. const Example
const country = "India";
console.log(country);
3. Arrow Function Example
const add = (a,b) => a+b;
console.log(add(5,3));
4. Template Literal Example
let name = "John";
console.log(`Hello ${name}`);
5. Destructuring Example
const user = {
name:"John",
age:20
};
const {name, age} = user;
6. Spread Operator Example
const arr1 = [1,2];
const arr2 = [...arr1,3,4];
console.log(arr2);
7. Rest Operator Example
function sum(...numbers){
console.log(numbers);
}
sum(1,2,3,4);
8. Class Example
class User{
constructor(name){
this.name = name;
}
show(){
console.log(this.name);
}
}
const user1 = new User("John");
user1.show();
9. Promise Example
let promise = new Promise((resolve,reject)=>{
resolve("Success");
});
promise.then(result=>console.log(result));
Important Points
- ES6 was introduced in 2015.
- ES6 makes JavaScript modern and easier.
- Arrow functions reduce code length.
- Promises help handle asynchronous tasks.
- Modern frameworks use ES6+ features.