The only way to truly test if a variable is undefined is to do the following. Remember, undefined is an object in JavaScript.
<!DOCTYPE html>
<html>
<body>
<script>
if (typeof someVar === 'undefined') {
alert("Your variable is undefined");
}
</script>
</body>
</html>
Most Helpful This Week
jQuery Show or Hide text on button click
Write a function that splits an array into groups the length of size and returns them as a two-dimensional array
jQuery show input text inside div after on click event
How to declare and print value of variable in JavaScript?
jQuery check if an element is visible or hidden
How to check if an element or HTML tag exists using JavaScript?