JavaScript MCQs with answers Page - 15

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 • 832.01K Points
Coach

Q. Which of the following values will be returned by the last statement in the given code?

Code:
functionconstfun()  
{  
var fun =[];  
for(vari=0;i<10;i++)  
        fun[i]=function(){returni;};  
return fun;  
}  
var fun =constfun();  
fun[5]()  
  • (A) 10
  • (B) 12
  • (C) 8
  • (D) 9

A

Admin • 832.01K Points
Coach

Q. What will be the correct output of the following JavaScript code?

Code:
<p id="demo"></p>  
<script>  
functionFunct()  
{  
document.getElementById("demo").innerHTML=Math.atan2(8,4);  
}  
</script>  
  • (A) 1.01
  • (B) 1.10
  • (C) 1.05
  • (D) 1.11

A

Admin • 832.01K Points
Coach

Q. What will be the correct output of the following JavaScript code?

Code:
<p id="demo"></p>  
<script>  
functionmyFunc()  
{  
document.getElementById("demo").innerHTML=Math.asinh(1);  
}  
</script>  
  • (A) 0.80
  • (B) 0.78
  • (C) 0.50
  • (D) 0.88

A

Admin • 832.01K Points
Coach

Q. What will happen if we execute the following code of JavaScript?

Code:
vartensquared=(function(x){return x*x;}(10));  
  • (A) Memory leak
  • (B) Error
  • (C) Exception will be thrown
  • (D) Yes, perfectly

A

Admin • 832.01K Points
Coach

Q. What output will come if we run the following part of the JavaScript code?

Code:
var string2Num=parseInt("123abc"); 
  • (A) Exception
  • (B) 123abc
  • (C) 123
  • (D) NaN

A

Admin • 832.01K Points
Coach

Q. Which one of the given options can be considered as a code equivalent to the following code?

Code:
var o =newObject();
  • (A) var o= new Object;
  • (B) var o;
  • (C) var o = Object();
  • (D) Object o=new Object();

A

Admin • 832.01K Points
Coach

Q. In the following code, what value should the variable "a" contain?

Code:
var x =counter(), y = counter();  
x.count()  
y.count()  
x.reset()  
x.count()  
y.count()  
  • (A) Null
  • (B) 0
  • (C) 2
  • (D) Undefined

A

Admin • 832.01K Points
Coach

Q. Which one of the given options can be considered as the correct output of the following code?

Code:
var addition=newFunction("number1","number2","return number1+number2");  
document.writeln(addition(10,5));  
  • (A) 12
  • (B) 13
  • (C) 15
  • (D) Error

A

Admin • 832.01K Points
Coach

Q. Which one of the following is not a example of closures?

  • (A) Graphics
  • (B) Variables
  • (C) Functions
  • (D) Objects

A

Admin • 832.01K Points
Coach

Q. What output will be returned by the function in the following code?

Code:
var scope ="global scope";  
functioncheckingscope()  
{  
var scope ="local scope";  
functionf()  
{  
return scope;  
}  
return f;  
}  
  • (A) It will returns the value in scope
  • (B) It will returns value null
  • (C) It will returns an exception
  • (D) It will show an error message

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