Consider the following JavaScript program:
var x, y, z;
function sub1() {
var a, y, z;
function sub2() {
var a, b, z;
. . .
}
. . .
}
function sub3() {
var a, x, w;
. . .
}
List all the variables; along with the program units where they are
declared, that are visible in the bodies of sub1, sub2, and sub3,
assuming static scoping is used.
Hi there,
If you still have any queries,feel free to ask in the comments box.
The variables x,y,z are global scope,so they can be used anywhere in the program units they are visible to all the bodies.
In sub1()
The variables visible are a,x,y,z.a is the local variable of that block it is visible only in that block.The redeclaration of y,z indicates that whatever new value of y,z be given in this block,it is updated globally.
In sub2()
The variables visible are a,b,x,y,z.a,b are the local variables of that block,it is visible only in that block.The redeclaration of y,z indicates that whatever new value of y,z be given in this block,it is updated globally.
In sub3()
The variables visible are a,w,x,y,z.a,w are the local variables of that block,it is visible only in that block.The redeclaration of x indicates that whatever new value of x be given in this block,it is updated globally.
Consider the following JavaScript program: var x, y, z; function sub1() { var a, y, z;...