How to determine if a variable is 'undefined' or 'null'?

JavascriptWeb DevelopmentFront End Technology

On getting the result of the following, you can find whether a variable is null or undefined. If the result is “false”, it means the variable is null and undefined.

Here, the variable results in “True” −

<html>
   <body>
      <script>
         var age = 10;

         if(age) {
            document.write("True");
         } else {
            document.write("False");
         }
      </script>
   </body>
</html>
raja
Published on 22-Jan-2018 16:19:03
Advertisements