Caching And Debugging(Javascript ) Questions and Answers

Question 1. What will happen if you reference document.location from within an object?
  1.    Traverses the queue
  2.    Finds the bugs
  3.    Traverses the stack
  4.    None of the mentioned
Explanation:-
Answer: Option C. -> Traverses the stack
If you reference document.location from within an object, the interpreter will need to go from the function that references the variable, up out of the namespace to the global window scope, down to the document scope, and get the location value.

Question 2. What does the interpreter do when you reference variables in other scopes?
  1.    Traverses the queue
  2.    Traverses the stack
  3.    Finds the bugs
  4.    None of the mentioned
Explanation:-
Answer: Option B. -> Traverses the stack
Normally when you reference variables in other scopes— at the global level, in other namespaces, and so on—the interpreter needs to traverse the stack to get to the variable.

Question 3. The attribute location belongs to which element?
  1.    document
  2.    html
  3.    image
  4.    pre
Explanation:-
Answer: Option A. -> document
The attribute location belongs to the document element.

Question 4. What is the next step after calling the startTimeLogging()?
  1.    Interpret the code
  2.    Compile the code
  3.    Run the code
  4.    None of the mentioned
Explanation:-
Answer: Option C. -> Run the code
Once the startTimeLogging() method is called, run the code to test.

Question 5. Why do we need to create locally scoped variables to hold value?
  1.    To optimize the testing process
  2.    To increase the speed
  3.    To minimize memory usage
  4.    To cache the reference document.location
Explanation:-
Answer: Option D. -> To cache the reference document.location
The locally scoped variables are created to cache the reference to document.location.

Question 6. What is the purpose of the method nodeMap.setNamedItem()?
  1.    Sets ID
  2.    Sets attribute node
  3.    Sets element name
  4.    None of the mentioned
Explanation:-
Answer: Option B. -> Sets attribute node
The method nodeMap.setNamedItem() sets the specified attribute node (by name).

Question 7. How is everything treated in HTML DOM?
  1.    Node
  2.    Attributes
  3.    Elements
  4.    All of the mentioned
Explanation:-
Answer: Option A. -> Node
In the HTML DOM (Document Object Model), everything is a node:
1. The document itself is a document node.
2. All HTML elements are element nodes.
3. All HTML attributes are attribute nodes.
4. Text inside HTML elements are text nodes.
5. Comments are comment nodes.

Question 8. What is the purpose of the Attr object in the HTML DOM?
  1.    Used to focus on a particular part of the HTML page
  2.    HTML Attribute
  3.    Used to arrange elements
  4.    None of the mentioned
Explanation:-
Answer: Option B. -> HTML Attribute
In the HTML DOM, the Attr object represents an HTML attribute.

Question 9. What is the work of the form control elements in the HTML DOM?
  1.    User Interface elements
  2.    All the possible elements
  3.    Debugging elements
  4.    None of the mentioned
Explanation:-
Answer: Option A. -> User Interface elements
Form control elements: The form object contains all the elements defined for that object such as text fields, buttons, radio buttons, and checkboxes.

Question 10. What does the NamedNodeMap object represent in the HTML DOM?
  1.    Unordered collection of elements
  2.    Unordered collection of attributes
  3.    Unordered collection of nodes
  4.    All of the mentioned
Explanation:-
Answer: Option D. -> All of the mentioned
In the HTML DOM, the NamedNodeMap object represents an unordered collection of an elements attribute nodes.