JavaScript MCQs with answers Page - 49

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. Which of the following are closures in Javascript?

  • (A) Variables
  • (B) Functions
  • (C) Objects
  • (D) All of the above

A

Admin • 833K Points
Coach

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

Code:
print(parseInt("123Hello"));
print(parseInt("Hello123"));
  • (A) 123 NaN
  • (B) 123Hello Hello123
  • (C) NaN NaN
  • (D) 123 123

A

Admin • 833K Points
Coach

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

Code:
a = [1, 2, 3, 4, 5];
print(a.slice(2, 4));
  • (A) 3, 4
  • (B) 2, 3
  • (C) 3, 4, 5
  • (D) 2, 3, 4

A

Admin • 833K Points
Coach

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

Code:
let sum = 0; 
const a = [1, 2, 3];
a.forEach(getSum);
print(sum);
function getSum(ele) {
   sum += ele;
}
  • (A) 6
  • (B) 1
  • (C) 2
  • (D) None of the above

A

Admin • 833K Points
Coach

Q. Which function is used to serialize an object into a JSON string in Javascript?

  • (A) stringify()
  • (B) parse()
  • (C) convert()
  • (D) None of the above

A

Admin • 833K Points
Coach

Q. The process in which an object or data structure is translated into a format suitable for transferral over a network, or storage is called?

  • (A) Object Serialization
  • (B) Object Encapsulation
  • (C) Object Inheritance
  • (D) None of the above

A

Admin • 833K Points
Coach

Q. What does the ‘toLocateString()’ method do in JS?

  • (A) Returns a localised object representation.
  • (B) Returns a parsed string.
  • (C) Returns a localized string representation of an object.
  • (D) None of the above.

A

Admin • 833K Points
Coach

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

Code:
print(typeof(NaN));
  • (A) Object
  • (B) Number
  • (C) String
  • (D) None of the above

A

Admin • 833K Points
Coach

Q. What is the output of the following code snippet?

Code:
print(NaN === NaN);
  • (A) true
  • (B) false
  • (C) undefined
  • (D) Error

A

Admin • 833K Points
Coach

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

Code:
var a = true + true + true * 3;
print(a)
  • (A) 3
  • (B) 0
  • (C) Error
  • (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