JavaScript MCQs with answers Page - 11

Here, you will find a collection of MCQ questions on JavaScript. Go through these questions to enhance your preparation for upcoming examinations and interviews.

To check the correct answer, simply click the View Answer button provided for each question.

Have your own questions to contribute? Click the button below to share your MCQs with others!

+ Add Question

A

Admin • 831.35K Points
Coach

Q. Which one of the following is correct output for the following given JavaScript code:

Code:
functionheight()  
{     
var  height=123.56;  
var type =(height>=190)?"Taller":"Little short";  
return type;  
}  
  • (A) 123.56
  • (B) Taller
  • (C) 190
  • (D) Little shorter

A

Admin • 831.35K Points
Coach

Q. Which one of the following is correct output for the following given JavaScript code:

Code:
string  X= "Good";  
string  Y="Evening";  
alert(X+Y);  
  • (A) Good
  • (B) Evening
  • (C) GooodEvening
  • (D) undefined

A

Admin • 831.35K Points
Coach

Q. Which one of the following is correct output for the following given JavaScript code

Code:
functionoutputfun(object)  
{  
    var place=object ?object.place: "Italy";  
    return "clean:"+ place;  
}  
console.log(outputfun({place:India}));  
  • (A) Error
  • (B) clean:Italy
  • (C) clean:India
  • (D) undefined

A

Admin • 831.35K Points
Coach

Q. Which one of the following is correct output for the following given JavaScript code:

Code:
<p id="demo"></p>  
<script>  
functionourFunction()  
{  
document.getElementById("demo").innerHTML=Math.abs(-7.25);  
}  
</script>  
  • (A) 7
  • (B) -7.25
  • (C) 25
  • (D) -7

A

Admin • 831.35K Points
Coach

Q. Which one of the following is correct output for the following given JavaScript code:

Code:
<p id="demo"></p>  
<script>  
function Function1()  
{  
document.getElementById("demo").innerHTML=Math.cbrt(792);  
}  
</script>  
  • (A) 972
  • (B) 81
  • (C) 9
  • (D) Error

A

Admin • 831.35K Points
Coach

Q. Which one of the following is correct output for the following given JavaScript code

Code:
<p id="demo"></p>  
<script>  
functionmyFunction()  
{  
document.getElementById("demo").innerHTML=Math.acos(0.5);  
}  
</script> 
  • (A) 01
  • (B) 4
  • (C) 00
  • (D) 047

A

Admin • 831.35K Points
Coach

Q. What we will get if we compare the "one" with "8" using the less than operator ("one"<8)?

  • (A) False
  • (B) True
  • (C) NaN
  • (D) Undefined

A

Admin • 831.35K Points
Coach

Q. Which one of the following is known as the Equality operator, which is used to check whether the two values are equal or not:

  • (A) =
  • (B) ===
  • (C) ==
  • (D) &&

A

Admin • 831.35K Points
Coach

Q. Which one of the following operator returns false if both values are equal?

  • (A) !
  • (B) !==
  • (C) !=
  • (D) All of the above

A

Admin • 831.35K Points
Coach

Q. What will be the output obtained by "shift ()" in the given code of JavaScript?

Code:
var a =[];  
a.unshift(5);  
a.unshift(22);  
a.shift();  
a.unshift(3,[4,5]);  
a.shift();  
a.shift();  
a.shift();  
  • (A) Exception is thrown
  • (B) [4,5]
  • (C) [3,4,5]
  • (D) 5

Add MCQ in this Category

If you want to share an MCQ question in this category, it's a great idea! It will be helpful for many other students using this website.

Share Your MCQ