With regard to the following JavaScript program, function main() { function sub1() var x = 10; function sub2() { var y = x; } function sub3() var x = 5; var x = 20; } 1) If it is interpreted using...


With regard to the following JavaScript program,


function main() {


function sub1()


var x = 10;


function sub2() {


var y = x;


}


function sub3()


var x = 5; var x = 20;


}


1) If it is interpreted using static-scoping rules. What value of x is displayed in functions sub1, sub2, and sub3 respectively? Why?


2) If it is under dynamic-scoping rules, what value of x is displayed in functions sub1, sub2, and sub3 respectively? Why?



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here