ExamVeda
Login
Home
41
Where are memory leaks found?
Discuss
Answer & Solution
Answer: Option A
Solution:
Memory leaks occur when we are developing client-side reusable scripting objects.
42
Which handler is triggered when the content of the document in the window is stable and ready for manipulation?
Discuss
Answer & Solution
Answer: Option A
Solution:
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.
43
What is the central concept of JavaScript memory management?
Discuss
Answer & Solution
Answer: Option B
Solution:
The central concept of JavaScript memory management is a concept of reachability.

1. 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.

2. Objects are kept in memory while they are accessible from roots through a reference or a chain of references.
44
When does a memory leak happen?
Discuss
Answer & Solution
Answer: Option A
Solution:
Memory leak happens when the browser for some reason doesn’t release memory from objects which are not needed any more.
45
The style property belongs to while of the following object?
Discuss
Answer & Solution
Answer: Option A
Solution:
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.
46
Which of the following functions are referenced internally?
Discuss
Answer & Solution
Answer: Option C
Solution:
Functions used in setTimeout/setInterval are referenced internally and tracked until complete, then cleaned up.
47
What is the purpose of destroying the functions and objects?
Discuss
Answer & Solution
Answer: Option D
Solution:
The primary purpose of a destroy function is to centralize the responsibility for cleaning up anything that the object has done that will:
1. Prevent its reference count from dropping to 0 (for example, removing problematic event listeners and callbacks and unregistering from any services).
2. Consume unnecessary CPU cycles, such as intervals or animations.
48
When does a cycle occur during memory leak?
Discuss
Answer & Solution
Answer: Option B
Solution:
A cycle happens when two objects reference each other in such a way that both objects retain each other.
49
Which of the following is a way to retain an object in memory?
Discuss
Answer & Solution
Answer: Option A
Solution:
One particularly obscure way to retain an object in memory is to log it to the console.
50
In which format does JavaScript support external JavaScript?
Discuss
Answer & Solution
Answer: Option A
Solution:
JavaScript supports external JavaScript, in the form of .js file.