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



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>
Updated on: 2020-06-15T09:13:24+05:30

870 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements