Question: Assume the following function definition and dynamic scoping rules: function f ( ) { function sub 2 ( ) { var x = 7 ;

Assume the following function definition and dynamic scoping rules:
function f(){
function sub2(){
var x =7;
sub1();
}
function sub1(){
var y = x;
}
var x =3;
sub2();
}
What would be the value assigned to variable y in sub1?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To solve this problem we need to understand the concept of dynamic scoping and apply it to the given ... View full answer

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 Databases Questions!