if (typeof (location.x != null) {
Using the above I run into the follow error: Uncaught TypeError: Cannot read property 'x' of null
I have tried console.log(location.x) which results in an example with null
if (location && location.x) {
}
typeof myVariable !== 'undefined is safer IMO -- no terrorist jQuery plugin can redefine undefined on you if you use typeof.You can just do:
if (location && location.x) {
}
Uncaught TypeError: Cannot read property 'x' of null
locationtends to be a bad variable name because ofwindow.location. One missvarand your "truthy" check will be true.== null.