Variables are Containers for Storing Data

JavaScript Variables can be declared in 4 ways:


Var Keyword:

The var keyword was used in all JavaScript code from 1995 to 2015.

The let and const keywords were added to JavaScript in 2015.

The var keyword should only be used in code written for older browsers.


Example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>JavaScript</title>
    <script>
        var x = "Hello";
        var y = "World";
        document.write(x + y);
    </script>
</head>
<body>
</body>
</html>