Course: JavaScript

Progress (0%)

  1. Foundation

  2. Numbers

  3. Strings

  4. Conditions

  5. Loops

  6. Arrays

  7. Functions

  8. Objects

  9. Exceptions

  10. HTML DOM

  11. CSSOM

  12. Events

  13. Drag and Drop

  14. opt Touch Events

  15. Misc

  16. Project: Analog Clock

HTML DOM - Documents Quiz

Quiz 24 9 questions

Prerequisites for the quiz

  1. HTML DOM — Documents
  2. All previous chapters

Are you ready?

9 questions to solve

Instructions
  1. This quiz goes to full-screen once you press the Start button.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
The return value of document.URL and document.documentURI would be the same for every single HTML document. True or false?
Both the properties URL and documentURI of the document object return exactly the same thing. It's just that URL is a bit newer and obviously simpler than documentURI. Hence, the correct choice is (A). For more info, please refer to HTML DOM — Documents.
For an HTML document, which of the following elements does document.documentElement return?
document.documentElement, for an HTML document, returns back the document's root element, which is simply <html>. Since there is no such choice given here, the correct answer is (D). For more info, please refer to HTML DOM — Documents.
What does the following code log?
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Simple web page</title>
</head>
<body>
   <div id="d1">A div</div>
</body>
</html>
var divElement = document.querySelector('#d1');
console.log(document.documentElement === divElement.parentNode);
The parentNode of divElement is the <body> element, however document.documentElement is the <html> element. Hence, the comparison would yield the Boolean false, and this goes with choice (B). For more info, please refer to HTML DOM — Documents.
document.images is the same as calling document.getElementsByTagName('img'). True or false?

(Note that this doesn't mean that both the expressions return the exact same object in memory.)

Yes, both the given expressions return the same kind of list (but obviously NOT the same object in terms of memory). Hence, the correct choice is (A). For more info, please refer to HTML DOM — Documents.
document.links is the same as calling...
Unlike its name, document.links returns back an HTMLCollection containing all the <a> elements in the underlying document, NOT the <link> elements. Hence, technically, calling document.getElementsByTagName('a') would give us the same result. Hence, the correct choice is (B). For more info, please refer to HTML DOM — Documents.
Consider the following HTML document:
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <title>Simple web page</title>
</head>
<body>
   <script>
      console.log(typeof document.title);
   </script>
</body>
</html>
document.title always returns back a string value. Thus, if we inspect it using typeof, we'd get 'string' returned. Hence, the correct choice is (A). For more info, please refer to HTML DOM — Documents.
Which of the following properties of the document object gives access to the Referer HTTP request header (if there is any) associated with the underlying document?
For more info, please refer to HTML DOM — Documents.
What does document.lastModified return if the underlying document doesn't have a Last-Modified HTTP response header associated with it?
For more info, please refer to HTML DOM — Documents.
Calling document.open() has no effect when the underlying document is still being loaded. True or false?
document.open() only has effect when the underlying document has been loaded completely, NOT when the document is still in the process of loading. Hence, the correct choice is (A). For more info, please refer to HTML DOM — Documents.