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