Javascript examples for Data Type:undefined
Assign undefined to a variable
<html> <head></head> <body> <button onclick="myFunction()">Click me</button> <!-- <input type="text" id="demo"></input> --> <script> function myFunction() {/*from www . j a v a 2 s . c o m*/ var message = undefined; if (document.getElementById("demo")) message = document.getElementById("demo").value; if ( message ) console.log(message); else console.log("undefined"); } </script> </body> </html>