1.

During the traversing of the stack when you create a locally scoped variable, where does it go after it goes to the namespace?(a) Window(b) Function(c) Document(d) LocationThis question was addressed to me in class test.The origin of the question is Cache Variables and Properties across Scope in chapter Caching, Debugging and Animation of JavaScript

Answer»

Right answer is (b) Function

Best explanation: Namespace in JavaScript is nothing but a single global object which will contain all our functions, methods, variables and all that. When you CREATE a locally scoped variable for CACHING the reference, the TRAVERSAL reverses in the FORWARD direction and thus, after going to the namespace, it goes to the function.



Discussion

No Comment Found

Related InterviewSolutions