JavaScript MCQs with answers Page - 47

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

Q. What will be the output of the following code snippet?

Code:
function solve(arr, rotations){
 if(rotations == 0) return arr;
 for(let i = 0; i < rotations; i++){
   let element = arr.pop();
   arr.unshift(element);
 }
 return arr;
}
// solve([44, 1, 22, 111], 5);
  • (A) [111, 44, 1, 22]
  • (B) [44, 1, 22, 111]
  • (C) [111, 44, 1, 22]
  • (D) [1, 22, 111, 44]

A

Admin • 833K Points
Coach

Q. What will be the output for the following code snippet?

Code:
<p id="example"></p>  
<script>  
function Func()  
{  
document.getElementById("example").innerHTML=Math.sqrt(81);  
}  
</script>
  • (A) 9
  • (B) 81
  • (C) Error
  • (D) 0

A

Admin • 833K Points
Coach

Q. When an operator’s value is NULL, the typeof returned by the unary operator is:

  • (A) Boolean
  • (B) Undefined
  • (C) Object
  • (D) Integer

A

Admin • 833K Points
Coach

Q. What will be the output of the following code snippet?

Code:
var a = 1;  
var b = 0;  
while (a <= 3)  
{  
   a++;  
   b += a * 2;  
   print(b);
}
  • (A) 4 10 18
  • (B) 1 2 3
  • (C) 1 4 7
  • (D) None of the above

A

Admin • 833K Points
Coach

Q. What does the Javascript “debugger” statement do?

  • (A) It will debug all the errors in the program at runtime.
  • (B) It acts as a breakpoint in a program.
  • (C) It will debug error in the current statement if any.
  • (D) All of the above.

A

Admin • 833K Points
Coach

Q. What will be the output of the following code snippet?

Code:
var a = Math.max() < Math.min();
var b = Math.max() > Math.min();
print(a);
print(b);
  • (A) true false
  • (B) false true
  • (C) true true
  • (D) false false

A

Admin • 833K Points
Coach

Q. Which of the following are not server-side Javascript objects?

  • (A) Date
  • (B) FileUpload
  • (C) Function
  • (D) All of the above

A

Admin • 833K Points
Coach

Q. What will be the output of the following code snippet?

Code:
const obj1 = {first: 20, second: 30, first: 50};
console.log(obj1);
  • (A) {first: 20, second: 30}
  • (B) {first: 50, second: 30}
  • (C) {first: 20, second: 30, first: 50}
  • (D) Syntax Error

A

Admin • 833K Points
Coach

Q. Which object in Javascript doesn’t have a prototype?

  • (A) Base Object
  • (B) All objects have a prototype
  • (C) None of the objects have a prototype
  • (D) None of the above

A

Admin • 833K Points
Coach

Q. How do we write a comment in javascript?

  • (A) /* */
  • (B) //
  • (C) #
  • (D) $ $

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