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?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here