My Report

JavaScript Objects Test – 2


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement

1. What will be the output of the following JavaScript code?

<p>1</p>
<p>2</p>
<p>3</p>
function myFunction() 
{
    var x = document.getElementsByTagName("P").item(0);
    alert(x.innerHTML);
}

2. What does the location property represent?

3. The history property belongs to which object?

4. The URL property belongs to which of the following object?

5. What will be the output of the following JavaScript code?

<p id="demo">head</p>
<button onclick="myFunction()">Try it</button>
<script>
function myFunction() 
{
   var x = document.getElementById("demo");
   x.innerHTML = x.attributes[0].isId;
}
</script>

6. The decodeURIComponent() is defined by _____________

7. What is the purpose of the assign() method?

8. What will be the output of the following JavaScript code?

<p>1</p>
<p>2</p>
<p>3</p>
function myFunction() 
{
   var l = document.getElementsByTagName("P").length;
   alert(l);
}

9. What is the function used to extract arguments from the search property of a URL?

10. What is the return type of the hash property?

11. Which among the following is not a property of the Location object?

12. Why is the replace() method better than the assign() method?

13. What will be the output of the following JavaScript code?

<head id="myHead">
</head>
<p id="demo"></p>
<script>
function myFunction() 
{
   var x = document.head.id;
   document.getElementById("demo").innerHTML = x;
}
</script>

14. What will be the output of the following JavaScript code?

<p id="Element">Head</p>
function myFunction() 
{
   var x = document.getElementsByTagName("P").namedItem("Element");
   alert(x.innerHTML);
}

15. Which is the method that removes the current document from the browsing history before loading the new document?


 

Start practicing “1000 MCQs on JavaScript”, and once you are ready, you can take tests on all topics by attempting our “JavaScript Test Series”.

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.