Q. Which of the following defines the Cookie visibility?

  • (A) document Path
  • (B) localStorage
  • (C) sessionStorage
  • (D) all of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (D) all of the mentioned
Explanation: Cookie visibility is scoped by document origin as localStorage and sessionStorage are, and also by document path.

Q. Which of the following can be used to configure the scope of the Cookie visibility?

  • (A) path
  • (B) domain
  • (C) both path and domain
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (D) none of the mentioned
Explanation: The Cookie visibility scope is configurable through cookie attributes path and domain.

Q. How can you set a Cookie visibility scope to localStorage?

  • (A) /
  • (B) %
  • (C) *
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) /
Explanation: Setting the path of a cookie to “/” gives scoping like that of localStorage and also specifies that the browser must transmit the cookie name and value to the server whenever it requests any web page on the site.

Q. Which of the following is a boolean cookie attribute?

  • (A) bool
  • (B) secure
  • (C) lookup
  • (D) domain
πŸ’¬ Discuss
βœ… Correct Answer: (B) secure
Explanation: The final cookie attribute is a boolean attribute named secure that specifies how cookie values are transmitted over the network. By default, cookies are insecure, which means that they are transmitted over a normal, insecure HTTP connection. If a cookie is marked secure, however, it is transmitted only when the browser and server are connected via HTTPS or another secure protocol.

Q. Which of the following function is used as a consequence of not including semicolons, commas or whitespace in the Cookie value?

  • (A) encodeURIComponent()
  • (B) encodeURI()
  • (C) encodeComponent()
  • (D) none of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (A) encodeURIComponent()
Explanation: Cookie values cannot include semicolons, commas, or whitespace. For this reason, you may want to use the core JavaScript global function encodeURIComponent() to encode the value before storing it in the cookie.

Q. What is the constraint on the data per cookie?

  • (A) 2 KB
  • (B) 1 KB
  • (C) 4 KB
  • (D) 3 KB
πŸ’¬ Discuss
βœ… Correct Answer: (C) 4 KB
Explanation: Each cookie can hold upto only 4 KB. In practice, browsers allow many more than 300 cookies total, but the 4 KB size limit may still be enforced by some.

Q. What does a Node object represent?

  • (A) Single node
  • (B) Set of nodes
  • (C) Sequence of nodes
  • (D) Node array
πŸ’¬ Discuss
βœ… Correct Answer: (A) Single node
Explanation: The Node object represents a single node in the document tree.

Q. What does the nodeName of the nodeType Document return?

  • (A) doctype name
  • (B) target
  • (C) #comment
  • (D) #document
πŸ’¬ Discuss
βœ… Correct Answer: (D) #document
Explanation: The nodeName of the nodeType Document returns #document.

Q. What is the purpose of the method item()?

  • (A) Returns node after the specified index
  • (B) Returns node before the specified index
  • (C) Returns node at specified index
  • (D) None of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (C) Returns node at specified index
Explanation: The method item() returns the node at the specified index in a node list.

Q. How can the nodes in the node list be accessed?

  • (A) Key
  • (B) Index number
  • (C) Looping
  • (D) All of the mentioned
πŸ’¬ Discuss
βœ… Correct Answer: (B) Index number
Explanation: The nodes in the node list can be accessed through their index number (starting from 0).