Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

JavaScript: Check if sub variable defined

How can I do this without errors?

 if (typeof (x) !== undefined && typeof (x.y) !== undefined) {
  alert('x.y not defined');
 }
 else {
  alert('x.y is defined');
 }

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial