*Variable: Variable is a name memory location used to store some values. Variables are mainly divided into two parts.
*1.Global Variable: In variable declaration in the global location we can access the global variable from any location within the script.
Global variables are destroyed when you close the page. If you declare a variable, without using "var", the variable always becomes GLOBAL.
*Local Variable : Variable declaration within the function. The accessible of scope from local variable is that function only. In variable declaration within the function without var is global variable.
You can have local variables with the same name in different functions, because local variables are only recognized by the function in which they are declared. Local variables are destroyed when you exit the function. You will learn more about functions in a later chapter of this tutorial.
Sample Java Script
<script>
var show=100;
function fun1()
var x=100;
var y=200;
z=300
fun2()
}
function fun2()
{
alert(z)
}
</script>
<input type="button" value="click" onClick="fun1()">
var show=100;
function fun1()
var x=100;
var y=200;
z=300
fun2()
}
function fun2()
{
alert(z)
}
</script>
<input type="button" value="click" onClick="fun1()">
0 comments:
Post a Comment