7. (12 points) 14. Consider the following program, written in JAVASCRIPT-LIKE sy
ID: 3709915 • Letter: 7
Question
7. (12 points) 14. Consider the following program, written in JAVASCRIPT-LIKE syntax: // main program var , Y 2 function subl var a, Y function sub2 0 var a, b, function sub3 0 var a, x, W Part1) Given the following calling sequences and assuming that dynamic scoping is used, what variables are visible during execution of the last subprogram activated? Include with each visible variable the name of the unit where it is declared. a. main calls subl; subl calls sub2: sub2 calls sub3. b. main calls subl: subl calls sub3 c. main calls sub2; sub2 calls sub3; sub3 calls subl d. main calls sub3; sub3 calls subl e. main calls subl; subl calls sub3; sub3 calls sub2 f. main calls sub3: sub3 calls sub2: sub2 calls subl Part2) Repeat Par' with a static scopingExplanation / Answer
Please find part 2..under below
Question A
<script>
const x=10;
const y=20;
const z=30;
function sub1(){
const a=90; const y=50; const z=50;
alert(a+y+z);
sub2();
}
function sub2(){
const a=90; const b=50; const z=20;
alert(a+b+z);
sub3();
}
function sub3(){
const a=90; const x=50; const w=10;
alert(a+x+w);
}
sub1();
</script>
Question B
<script>
const x=10;
const y=20;
const z=30;
function sub1(){
const a=90; const y=50; const z=50;
alert(a+y+z);
sub3();
}
function sub2(){
const a=90; const b=50; const z=20;
alert(a+b+z);
}
function sub3(){
const a=90; const x=50; const w=10;
alert(a+x+w);
}
sub1();
</script>
Question C
<script>
const x=10;
const y=20;
const z=30;
function sub1(){
const a=90; const y=50; const z=50;
alert(a+y+z);
}
function sub2(){
const a=90; const b=50; const z=20;
alert(a+b+z);
sub3();
}
function sub3(){
const a=90; const x=50; const w=10;
alert(a+x+w);
sub1();
}
sub2();
</script>
Question D
<script>
const x=10;
const y=20;
const z=30;
function sub1(){
const a=90; const y=50; const z=50;
alert(a+y+z);
}
function sub2(){
const a=90; const b=50; const z=20;
alert(a+b+z);
}
function sub3(){
const a=90; const x=50; const w=10;
alert(a+x+w);
sub1();
}
sub3();
</script>
Question E
<script>
const x=10;
const y=20;
const z=30;
function sub1(){
const a=90; const y=50; const z=50;
alert(a+y+z);
sub3();
}
function sub2(){
const a=90; const b=50; const z=20;
alert(a+b+z);
}
function sub3(){
const a=90; const x=50; const w=10;
alert(a+x+w);
sub2();
}
sub1();
</script>
Question F
<script>
const x=10;
const y=20;
const z=30;
function sub1(){
const a=90; const y=50; const z=50;
alert(a+y+z);
}
function sub2(){
const a=90; const b=50; const z=20;
alert(a+b+z);
sub1();
}
function sub3(){
const a=90; const x=50; const w=10;
alert(a+x+w);
sub2();
}
sub3();
</script>
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.