What is the output of the following JavaScript code? | Question 3

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

<script>
	var x = 5;
	document.getElementById("demo").innerHTML = x--;
</script>
  1. 5
  2. 4
  3. TypeError
  4. ValueError

Answer: B) 4

Explanation:

The output of the above statement will be 5.

In the above statement, we used post-decrement (x--). Post-decrement decreases the value by 1 after evaluating the current statement.

Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.