What are Scoping Rules? Why are they so Important in all Programming Languages?

Scoping is an important concept in programming.

Scope determines how a variable can be accessed.

In java script variables can be either local (or) global.

Global:- 

Global scoping means that a variable is available to all parts of the program. Such variables are declared outside of any function and are usually used to hold static data, that you won’t alter once it has been declared.

Local:- 

Local variables are declared inside a function. They can only be used by that function. If you want the value associated with a local variable to be available to other functions.You must pass it as parameter.

<html>
<head>
<title> global & local </title>
<script language = “ java script”>
  var a = 32;
  var temp = a;
  var b = set – local (17);
  document .write (“The global is “ + a);
  document. write (“ b is “ + b);
  function set_ local (num)
   {
      var a = num;
       alert = (“temp is “ + temp);
       return(a);
   }
</script>
</head>
<body>- - - -</body>
</html> 

Related

Web Technology 8606868384245559878

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item