Organizational Research By

Surprising Reserch Topic

Experts Most Trusted Topic


How to check for “undefined” in JavaScript?


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?

 


asked Jun 30, 2015 in JAVASCRIPT by rajesh
0 votes
51 views



Related Hot Questions



Government Jobs Opening


...