javascript - 理解 If 语句中的 Javascript 对象
问题描述
我正在尝试修改此 javascript 以检索地点信息,但我无法弄清楚 if 语句在此处的示例中正在评估什么:https ://developers.google.com/maps/documentation/javascript/examples/places-autocomplete-地址表
我不明白正在评估的具体 if 语句是:
if (componentForm[addressType]) {
var val = place.address_components[i][componentForm[addressType]];
document.getElementById(addressType).value = val;
}
解决方案
这将检查componentForm[addressType]
is not undefined、null、empty string、0、NaN或false。
推荐阅读
- python - Python/Django remove text in variable
- c - 如何在 15 和 18 处处理此警告。“警告:数组下标的类型为 'char' [-Wchar-subscripts]”
- javascript - My class created doesn't export an object
- php - 如何使用 microsoft-graph sdk php 让 Outlook 免费繁忙的日程安排
- css - Chrome浏览器中css网格的奇怪行为?
- python - 如何在 python 的推文列上应用 coreNlp(Stanford NLP)?
- fastlane - bitrise 在 Applications/Xcode-beta.app/Contents/Developer 找不到传输器
- node.js - Puppeteer 从 elementHandle 获取元素导致协议错误
- spring - 如何在spring boot中配置多个身份验证提供?
- javascript - 带有滞后的移动按钮控件的 JavaScript 游戏