Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following JavaScript program: var x, y, z; function sub1() { var a,

ID: 3678453 • Letter: C

Question

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.

What arguments can you make for the idea of a single language for all programming domains?                                                                                                                 

           

Explanation / Answer

Point 1 - In sub2:

a, b, z in sub2.

y in sub1 (a and z of sub1 are hidden).

x the global variable (global variables y and z are hidden).

Point 2 - In sub1:

a, y, z in sub1.

x the global variable (global variables y and z are hidden).

Point 3 - In sub3:

a, x, w in sub3.

y, z the global variables (global variable x is hidden).

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote