Scope of Variable and Argument



Write a javascript code to demonstrate scope of variable.

<html>
  <head>
    <title>Function Demo</title>
      <script>

        var g ="Welcome"; //Globally declared variable

        function display()
        {
            var l="Thanks"; // Locally declared variable
        
            document.write("Global Value ="+g);
            document.write("Local Value ="+l);
        }
        display();

      </script>
    </head>
  <body>       
</body>
</html>

Output:

Global Value =Welcome
Local Value =Thanks Name=Jhon
Age=23
Language=English