FeatureDescriptionExample
letBlock scope variablelet age = 20;
constConstant variableconst PI = 3.14;
Arrow FunctionShort function syntaxconst add = (a,b) => a+b;
Template LiteralsString interpolation using backticks`Hello ${name}`
DestructuringExtract values from objects/arraysconst {name} = user;
Spread OperatorCopy or merge arrays/objects[...arr]
Rest OperatorHandle multiple function argumentsfunction sum(...num)
Default ParametersSet default function valuesfunction test(x=1)
ClassesCreate objects using class syntaxclass User{}
ModulesImport and export filesimport app from './app.js'
PromisesHandle asynchronous operationsnew Promise()
for...of LoopLoop through array valuesfor(let value of arr)
Map ObjectStore key-value pairsnew Map()
Set ObjectStore unique valuesnew Set()
SymbolCreate unique identifiersSymbol("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.