(1)Variable example in javascript:
<html>
<head>
<script>
var x = 10;
var y = 20;
var z=x+y;
document.write(z);
</script>
</head>
<body>
</body>
</html>
(2)Global variable example:
<html>
<head>
<script>
var data=200;//gloabal variable
function a(){
document.writeln(data);
}
function b(){
document.writeln(data);
}
a();//calling JavaScript function
b();
</script>
</head>
<body>
</body>
</html>
Comments
Post a Comment