Question: Question 2 With regard to the following JavaScript program, var x; function sub 1 ( ) { document.write ( x = + x

Question 2
With regard to the following JavaScript program,
var x;
function sub1(){
document.write("x ="+ x +"");
}
function sub20{
var x;
x}=10
sub10;
}
x}=5\mathrm{ ;
sub2();
If it is interpreted using static-scoping rules. What value of x is displayed in
function sub1? Why?
If it is under dynamic-scoping rules, what value of x is displayed in function sub1? Why?
With regard to the following JavaScript program,
function main(){
function sub10
var x =10;
function sub20{
var y = x;
}
function sub30
var x =5;
var x =20;
}
If it is interpreted using static-scoping rules. What value of x is displayed in
functions sub1, sub2, and sub3 respectively? Why?
If it is under dynamic-scoping rules, what value of x is displayed in functions sub1, sub2,
and sub 3 respectively? Why?
Question 2 With regard to the following

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!