Prev Demo
JavaScript
>
Undefined Property
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> </head> <body> <p>Click the below button to check whether the variable is undefined.</p> <input type="button" onclick="mySearch()" value="Search"> <p id="myId"></p> <script> function mySearch() { var A; //* Here we did not defined with any value to the variable A *// if (A === undefined) { R = "A is undefined"; } else { R = "A is defined"; } document.getElementById("myId").innerHTML = R; } </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output