JavaScript MCQs with answers Page - 56

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. How do you find the greatest value of “a” and “b”?

  • (A) Math.ceil(a, b)
  • (B) Math.max(a, b)
  • (C) ceil(a, b)
  • (D) top(a, b)

A

Admin • 833K Points
Coach

Q. How can you add a comment in JavaScript code?

  • (A) //This is a comment
  • (B) "This is a comment"
  • (C) #This is a comment
  • (D) None of these

A

Admin • 833K Points
Coach

Q. JavaScript is the same as Java?

  • (A) True
  • (B) False
  • (C) ---
  • (D) ---

A

Admin • 833K Points
Coach

Q. How to round the number 3.12 to a closer integer number?

  • (A) Math.round(3.12)
  • (B) Math.rnd(3.12)
  • (C) float(3.12)
  • (D) Math.float(3.12)

A

Admin • 833K Points
Coach

Q. What is the correct syntax of the “while” loop?

  • (A) while (i <= 5)
  • (B) while i = 1 to 5
  • (C) while (i <= 5; i++)
  • (D) while (i=0; i <= 5; i++)

A

Admin • 833K Points
Coach

Q. What is the correct syntax of the “for” loop?

  • (A) for (i <= 10; i++)
  • (B) for i = 1 to 10
  • (C) for (i = 0; i <= 10)
  • (D) for (i = 0; i <= 10; i++)

A

Admin • 833K Points
Coach

Q. What is the correct syntax for opening a new window called “f2”?

  • (A) f2 = window.new("https://example.com");
  • (B) f2 = window.open("https://example.com");
  • (C) f2 = document.open("https://example.com");
  • (D) f2 = document.new("https://example.com");

A

Admin • 833K Points
Coach

Q. What is the correct syntax to write an array in JavaScript?

  • (A) var fruits = 1 = ("orange"), 2 = ("banana"), 3 = ("apple")
  • (B) var fruits = (1:"orange", 2:"banana", 3:"apple")
  • (C) var fruits = "orange", "banana", "apple"
  • (D) var fruits = ["orange", "banana", "apple"]

A

Admin • 833K Points
Coach

Q. What is the output of : String.fromCharCode(65)?

  • (A) 1
  • (B) A
  • (C) error
  • (D) false

A

Admin • 833K Points
Coach

Q. What event do you use to perform something after the page has finished loading?

  • (A) onfinished
  • (B) onload
  • (C) onunload
  • (D) oncomplete

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