首页 > 解决方案 > 理解 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;
      }

标签: javascript

解决方案


这将检查componentForm[addressType]is not undefinednullempty string0NaNfalse


推荐阅读