976). Where are memory leaks found?
[A] Client side objects
[B]Server side objects
[C]Both Client side and Server side objects
[D]User side objects
Show Answer
Correct Answer: Client side objects
Notes:
Answer: a
Explanation: Memory leaks happen when your code needs to consume memory in your application, which should be released after a given task is completed but isn’t. Memory leaks occur when we are developing client-side reusable scripting objects.
977). Which handler is triggered when the content of the document in the window is stable and ready for manipulation?
[A]onload
[B]manipulate
[C]create
[D]oncreate
Show Answer
Correct Answer: onload
Notes:
Answer: a
Explanation: One of the most important event handlers is the onload handler of the Window object. It is triggered when the content of the document displayed in the window is stable and ready to be manipulated. JavaScript code is commonly wrapped within an onload event handler.
978). What is the central concept of JavaScript memory management?
[A]Reliability
[B]Reachability
[C]Efficiency
[D]Transparency
Show Answer
Correct Answer: Reachability
Notes:
Answer: b
Explanation: The central concept of JavaScript memory management is a concept of reachability. The main cause for leaks in garbage collected languages are unwanted references.
A distinguished set of objects are assumed to be reachable: these are known as the roots. Typically, these include all the objects referenced from anywhere in the call stack (that is, all local variables and parameters in the functions currently being invoked), and any global variables.
Objects are kept in memory while they are accessible from roots through a reference or a chain of references.
979). When does a memory leak happen?
[A]Browser doesn’t release memory from objects unnecessary
[B]Browser releases too many memories
[C]Browser releases memory iteratively
[D]Browser releases memory quickly
Show Answer
Correct Answer: Browser doesn’t release memory from objects unnecessary
Notes:
Answer: a
Explanation: Memory leaks happen when your code needs to consume memory in your application, which should be released after a given task is complete but isn’t. Memory leak happens when the browser for some reason doesn’t release memory from objects which are not needed any more.
980). What will happen when the data of the jQuery.cache is read from an element?
[A]Unique number is retrieved as elem[jQuery.expando]
[B]Data is read from jQuery.cache[id]
[C]Unique number is retrieved as elem[jQuery.expando] & Data is read from jQuery.cache[id]
[D] Data is cleared from jQuery.cache[id]
Show Answer
Correct Answer: Unique number is retrieved as elem[jQuery.expando] & Data is read from jQuery.cache[id]
Notes:
Answer: c
Explanation: jQuery.cache[id] is used to associate handlers and other data with elements. When the data is read from an element:
The element unique number is retrieved from id = elem[ jQuery.expando].
The data is read from jQuery.cache[id].
981). The style property belongs to which of the following object?
[A]Element
[B]Window
[C]Location
[D]Navigation
Show Answer
Correct Answer: Element
Notes:
Answer: a
Explanation: Each Element object has style and className properties that allow scripts to specify CSS styles for a document element or to alter the CSS class names that apply to the element.
982). Which of the following functions are referenced internally?
[A]setTimeout
[B]setInterval
[C]both setTimeout and setInterval
[D]clearInterval
Show Answer
Correct Answer: both setTimeout and setInterval
Notes:
Answer: c
Explanation: setTimeout(function, milliseconds) executes a function, after waiting a specified number of milliseconds. Functions used in setTimeout/setInterval are referenced internally and tracked until complete, then cleaned up.
983). What is the purpose of destroying the functions and objects?
[A]Consume unnecessary CPU cycles
[B] Prevent the dropping of reference count to 0
[C]Centralize the responsibility to clean up
[D] All of the mentioned
Show Answer
Correct Answer: All of the mentioned
Notes:
Answer: d
Explanation: The primary purpose of a destroy function is to centralize the responsibility for cleaning up anything that the object has done that will:
Prevent its reference count from dropping to 0 (for example, removing problematic event listeners and callbacks and unregistering from any services).
Consume unnecessary CPU cycles, such as intervals or animations.
984). When does a cycle occur during memory leak?
[A]No reference occurs
[B]Two objects reference
[C]One object gets referenced
[D]Three object gets referenced
Show Answer
Correct Answer: Two objects reference
Notes:
Answer: b
Explanation: Old versions of Internet Explorer could not detect cyclic references between DOM nodes and JavaScript code. A cycle happens when two objects reference each other in such a way that both objects retain each other.
985). Which of the following is a way to retain an object in memory?
[A]Console Log
[B]Closures
[C]Destroy objects
[D]Clear object
Show Answer
Correct Answer: Console Log
Notes:
Answer: a
Explanation: Any object inside the timer will hold a reference in order to run that piece of code somewhere in the future without any problems. One particularly obscure way to retain an object in memory is to log it to the console.