• support@answerspoint.in

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

23
Advertisement

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        
       
  • publish 10 years ago
  • viewed 23 times
  • active 10 years ago

Best Rated Questions