Skip to main content

Command Palette

Search for a command to run...

Knowledge Check - JavaScript in the browser

Updated
1 min read
Knowledge Check - JavaScript in the browser
D

A passionate full-stack developer from @ePlus.DEV

  1. In the following code, the type attribute can be omitted.

     <script type="text/javascript">
         //Comment
     </script>
    
    • true

    • false

  2. What does the document variable return in JavaScript?

     console.log(document);
    
    • The entire body tag of the webpage in the browser's memory, as a JavaScript object.

    • The entire webpage in the browser's memory, as a JavaScript object.

    • The HTML code of the downloaded webpage, as a JavaScript string.

  3. What does the following function return?

     getElementById('main-heading')
    
    • It doesn't return anything.

    • All elements that have the class attribute with a value main-heading

    • The first element that has the id attribute with a value main-heading

    • The last element that has the id attribute with a value main-heading

  4. After the following code is run, what will happen when the user clicks on a p element in the browser?

     document.querySelector('h1').addEventListener('click', function() { 
         console.log('clicked');
     });
    
    • 'clicked' is printed to the console log.

    • Nothing.

  5. What will be printed when the following code runs?

     var result = {
         value: 7
     };
     console.log(JSON.stringify(result));
    
    • {}

    • {value: 7}

    • {"value": 7}

More from this blog

E

ePlus.DEV - Exploring Technology with David Nguyen

1230 posts

A passionate full-stack developer from VIETNAM.

\n\n\ntrue\n\nfalse\n\n\n\nWhat does the document variable return in JavaScript?\n console.log(document);\n\n\nThe entire body tag of the webpage i...","author":{"@type":"Person","name":"David Nguyen","url":"https://hashnode.com/@hoangit","image":"https://cdn.hashnode.com/res/hashnode/image/upload/v1683641989003/8G4Xb70Ot.png","sameAs":"https://x.com/david_nguyen94"},"publisher":{"@type":"Organization","name":"ePlus.DEV - Exploring Technology with David Nguyen","url":"https://eplus.dev","logo":"https://cdn.hashnode.com/uploads/logos/5f802df9bbabf10ec84d9fe8/dfa3799e-75c5-47a1-99e5-cdcf872ce219.png"},"datePublished":"2024-07-20T04:01:24.723Z","dateModified":"2024-10-16T14:55:39.814Z","image":{"@type":"ImageObject","url":"https://cdn.hashnode.com/res/hashnode/image/upload/v1721448036398/8c182644-9516-47e7-85ef-86bb3c459b74.png"}}