1.

Why do we need to create locally scoped variables to hold value?(a) To optimize the testing process(b) To increase the speed(c) To minimize memory usage(d) To cache the reference document.locationThis question was addressed to me during an online exam.My enquiry is from Cache Variables and Properties across Scope topic in chapter Caching, Debugging and Animation of JavaScript

Answer»

The correct option is (d) To cache the REFERENCE DOCUMENT.location

To EXPLAIN: window.location.assign LOADS a new document. The locally scoped VARIABLES are created to cache the reference to document.location.



Discussion

No Comment Found

Related InterviewSolutions