JavaScript MCQs with answers Page - 22

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 JavaScript code?

Code:
<script>
	var x = 10 + 20 * 5;
	document.getElementById("tes").innerHTML = x;
</script>
  • (A) 110
  • (B) 150
  • (C) TypeError
  • (D) ValueError

A

Admin • 833K Points
Coach

Q. JavaScript arrays are written with _____.

  • (A) round brackets ()
  • (B) curly brackets {}
  • (C) double quotes ""
  • (D) square brackets []

A

Admin • 833K Points
Coach

Q. JavaScript objects are written with _____.

  • (A) round brackets ()
  • (B) curly brackets {}
  • (C) double quotes ""
  • (D) square brackets []

A

Admin • 833K Points
Coach

Q. Which JavaScript operator is used to determine the type of a variable?

  • (A) typeof
  • (B) TypeOf
  • (C) typeOf
  • (D) sizeof

A

Admin • 833K Points
Coach

Q. Which is the correct syntax of JavaScript typeof operator?

  • (A) typeof variable/value
  • (B) typeof(variable/value)
  • (C) Both A and B.
  • (D) None of the above

A

Admin • 833K Points
Coach

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

Code:
<script>
	var x = 12.34;
	document.getElementById("test").innerHTML = typeof(x);
</script>
  • (A) int
  • (B) float
  • (C) long
  • (D) number

A

Admin • 833K Points
Coach

Q. Which keyword is used to define a JavaScript function?

  • (A) module
  • (B) fun
  • (C) func
  • (D) function

A

Admin • 833K Points
Coach

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

Code:
<script>
	function addition(a, b) {
		return a+b;
	}
	document.getElementById("test").innerHTML = addition;
</script>
  • (A) SyntaxError
  • (B) ValueError
  • (C) 0
  • (D) function addition(a, b) { return a+b; }

A

Admin • 833K Points
Coach

Q. In JavaScript a variable contains one value while an object may contain ___.

  • (A) One value
  • (B) Two values
  • (C) Three values
  • (D) Many values

A

Admin • 833K Points
Coach

Q. Which is the correct syntax to access an object property in JavaScript?

  • (A) objectName:propertyName
  • (B) propertyName
  • (C) objectName["propertyName"]
  • (D) Both B and C.

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