JavaScript MCQs with answers Page - 52

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. Can we create empty array in Javascript? Find the output of below code

Code:
<script>

var firstNames = []; //creating empty array

for (var i = 0; i <=firstNames.length; i++) {
document.write("Javascript");
}

</script>
  • (A) Error
  • (B) Nothing is printed
  • (C) Javascript
  • (D) JavascriptJavascript

A

Admin • 833K Points
Coach

Q. What is the output of Math.ceil(0) in Javascript?

Code:
<script>
var mathVal = Math.ceil(0);
document.write(mathVal);
</script>
  • (A) 0
  • (B) 1
  • (C) NaN
  • (D) None of the above

A

Admin • 833K Points
Coach

Q. Find the output of below code

Code:
<html>
<head>
<title>JavaScript Example</title>
 
<script type="text/javascript">
function getHeader() {
    return "<h1>Javascript Questions</h1>"
}
</script>

</head>
<body>
<script type="text/javascript">
    document.write(getHeader());
</script>

</body>
</html>
  • (A) Javascript Questions
  • (B) <h1>Javascript Questions</h1>
  • (C) "<h1>Javascript Questions</h1>"
  • (D) Error

A

Admin • 833K Points
Coach

Q. Which of the following is not a built-in String method in Javascript?

  • (A) search()
  • (B) slice()
  • (C) append()
  • (D) replace()

A

Admin • 833K Points
Coach

Q. What if you use parseInt() to convert a string containing decimal value?

  • (A) If returns only the integer portion of the number
  • (B) It returns the decimal values in string form
  • (C) Throws Error
  • (D) None of the listed option

A

Admin • 833K Points
Coach

Q. What is the output of below Javascript code?

Code:
alert (typeof new Date() ); 

  • (A) Current Date
  • (B) Displays Nothing
  • (C) object
  • (D) Throws Error

A

Admin • 833K Points
Coach

Q. Which event occurs when the value of an element has been changed?

  • (A) onchange
  • (B) focuschange
  • (C) onsubmit
  • (D) onclick

A

Admin • 833K Points
Coach

Q. Which of the following tag is used to draw graphics on the fly in Javascript?

  • (A) Draw
  • (B) MoveCursor
  • (C) Canvas
  • (D) Image

A

Admin • 833K Points
Coach

Q. The keyword or the property that you use to refer to an object through which they were invoked is

  • (A) from
  • (B) to
  • (C) this
  • (D) object

A

Admin • 833K Points
Coach

Q. The basic difference between JavaScript and Java is

  • (A) There is no difference
  • (B) Functions are considered as fields
  • (C) Variables are specific
  • (D) Functions are values, and there is no hard distinction between methods and fields

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