我以为我已经正确地遵循检查undefined
建议in this question:不知道这有什么错这个JavaScript“未定义”检查
if(typeof window.session.location.address.city != "undefined")
console.log(window.session.location.address.city);
但上面的代码生成此错误:
Uncaught TypeError: Cannot read property 'city' of undefined
什么执行此检查的正确方法?