Here are some examples with commenting.  Following topics we are going to cover.

  • Difference between let and var
  • Object destructuring
  • Template String
  • Default Arguments
  • Object Property
  • Arrow Function
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=, initial-scale=1.0">
    <title>Basics of javascript ES5 & ES6</title>
</head>
<body>
    
    <script>
        /*
        *
        *   Difference between let and var
        *    
        */
        // after assigning could not change the value
        const students = 25;

        // scope of var with in function
        function testing_var(){
            var age = 20;
            if(true){
                var age = 10;
                console.log("var with in if: "+age);
            }

            console.log("var with in function: "+age);
        }
        testing_var();

        // scope of let with in block
        function testing_let(){
            let age = 20;
            if(true){
                let age = 10;
                console.log("let with in if: "+age);
            }

            console.log("var with in function: "+age);
        }
        testing_let();

        /*
        *
        *   Object destructuring
        * 
        */
        // creating an object
        var std1 = {name: "Ahmed", age: 20, address: "Sialkot"};

        console.log("Getting object value: "+ std1.name);

        //destructuring
        var {name, age, address} = std1;

        console.log("Name After Destructuring: "+ name);
        console.log("Age After Destructuring: "+ age);
        console.log("Address After Destructuring: "+ address);

        /*
        *
        *   Template Strings
        * 
        */
        //without template string
        console.log("Student Name Is: "+ name + ". Student age is: "+ age +". Student Address is: "+ address);
        
        //with string templating
        console.log(`Student Name is: ${name}. Studnet age is ${age}. Student Address is: ${address}`);

        /*
        *
        *   Default Arguments
        * 
        */
        function get_std_address( address = "Gujrat"){
                console.log(address);
        }

        get_std_address();
        get_std_address(address);

       /*
        *
        *   Object Property
        * 
        */
        //without object property
        var std1_detail = {name: name, age: age, address: address};

        console.log(std1_detail);

        //with object property
        
        var std1_detail = {name, age, address};

        console.log(std1_detail);

        /*
        *
        *   Arrow Function
        * 
        */
        var get_std_detail = (name, age, address) => {
            console.log(`Student Name is: ${name}. Studnet age is ${age}. Student Address is: ${address}`);
        };

        get_std_detail(name, age, address);
    </script>
</body>
</html>