• support@answerspoint.com

How to check for “undefined” in JavaScript? [duplicate]

407

What is the most appropriate way to test if a variable is undefined in JavaScript? I've seen several possible ways:

if (window.myVariable)

Or

if (typeof(myVariable) != "undefined")

Or

if (myVariable) //This throws an error if undefined. Should this be in Try/Catch?

0Answer


Your Answer

    Facebook Share        
       
  • asked 3 years ago
  • viewed 407 times
  • active 3 years ago

Hot Questions