我以爲我已經正確地遵循檢查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
什麼執行此檢查的正確方法?