Question: Consdier the following program (as we discussed in the class). What value of x is displayed in function sub1? Select one best answer. /* program
Consdier the following program (as we discussed in the class). What value of x is displayed in function sub1? Select one best answer.
/* program begins here */ var x;
function sub1( ) {
document.write("x = " + x + "
");
}
function sub2( ) { var x;
x = 10;
sub1( );
}
x = 5;
sub2( );
/* program ends here */
5 with static scoping, 10 with dynamic scoping
10 with static scoping, 5 with dynamic scoping
5 with static or dynamic scoping
10 with static or dynamic scoping
undefined for static scoping
undefined with dynamic scoping
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
