Use empty string in if statement - Javascript Statement

Javascript examples for Statement:if

Description

Use empty string in if statement

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <script type="text/javascript">
function disp_prompt() {//from   ww  w. j  a  v a  2  s  . c  o  m
    var name = "";
    if (name) {
        window.document.write("<p>Hello " + name + "! How are you today?<\/p>");
    }
}

      </script> 
   </head> 
   <body> 
      <input type="button" onclick="disp_prompt()" value="Display a prompt box">  
   </body>
</html>

Related Tutorials