Skip to content

Check if a variable exists in JavaScript

Find out how to find out if a variable exists in JavaScript.

 var num = 20;
 if(num !== undefined && num !== null) {
     document.write("Variable 'num' exists");
 }
See also  Pad a number to two digits with Javascript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.