Question: Due: 1 1 : 5 9 PM , 1 0 / 0 7 / 2 0 2 4 The answers must be typed. Question 1

Due: 11:59 PM,10/07/2024
The answers must be typed.
Question 1
With regard to the following JavaScript program,
function main(
function sub1()
var x =10;
function sub2(){
vars y = x;
}
function sub3()
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 sub3 respectively? Why?
Question 2
With regard to the following JavaScript program,
var x ;
function sub1(){
dacumentwrite("x ="+ x +"");
}
function sub2(){
var x ;
Due: 1 1 : 5 9 PM , 1 0 / 0 7 / 2 0 2 4 The

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!