Home »
MCQs »
JavaScript MCQs
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>
- 5
- 4
- TypeError
- 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.