1.

What is the opposite approach to the lexical scoping?(a) Literal scoping(b) Static scoping(c) Dynamic scoping(d) Generic scopingThis question was posed to me in a job interview.Origin of the question is Closures topic in division Lexical Structures of JavaScript

Answer»

The correct OPTION is (c) Dynamic scoping

To explain: The opposite approach to the LEXICAL scoping is the dynamic scoping. Dynamic scoping does not care how the code is written, but instead how it executes. Each time a new function is executed, a new scope is PUSHED onto the stack. This scope is typically stored with the function’s call stack. When a variable is REFERENCED in the function, the scope in each call stack is checked to see if it provides the value.



Discussion

No Comment Found

Related InterviewSolutions