निम्नलिखित जावास्क्रिप्ट कोड का आउटपुट क्या है?
What is the output of the following JavaScript code ?
<script>
var a;
document.getElementById("demo").innerHTML = a+1;
</script>
A
0
B
undefined
C
1
D
NaN
Explanation
In the given JavaScript code:
var a;
document.getElementById("demo").innerHTML = a + 1;
- The variable
ais declared but not initialized, so its value isundefined. - When you try to add
undefinedto1, the result will beNaN(Not a Number).
So, the correct answer is:
(D) NaN.
Correct Answer: D) NaN