Variables (Let & Const) tutorial in JavaScript

 <!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Variable Let & Const</title>
    <script>
        //variable with "var"
        var firstname = "Hello<br>";
        var firstname = "How are you ?";    //We can redeclare variable name with "var"
        firstname = "World<br>";
        document.write(firstname);

        //variable with "let"
        let secondname = "second<br>";
        // let secondname = "shflsh<br>";  //We can not redeclare variable name with "let"
        secondname = "name<br>";
        document.write(secondname);

        //constant variable with "const"
        const thirdname = "Hello<br>";
        // const thirdname = "Hello brother<br>";  //We can not redeclare variable name with "const"
        // thirdname = "How much time ?<br>";  //We can not reassign variable value with "const"
        document.write(thirdname);
    </script>
</head>

<body>
    <h1>Variable Let & Const</h1>
</body>

</html>



Comments

Popular posts from this blog

Symbols tutorial in Advance JavaScript

Async and Await Method tutorial in Advance JavaScript

String Methods in JavaScript