Javascript 如何修复限定符可以为null?
我有一个剑道组合框,我正在检查它是否已被实例化,我正在使用typeof进行检查,但得到一个警告(不确定这是否重要,但我正在使用ReSharper),并且不确定如何解决该问题Javascript 如何修复限定符可以为null?,javascript,jquery,Javascript,Jquery,我有一个剑道组合框,我正在检查它是否已被实例化,我正在使用typeof进行检查,但得到一个警告(不确定这是否重要,但我正在使用ReSharper),并且不确定如何解决该问题 const exclusiveToSpecificVendor = $("#VendorList").data("kendoComboBox"); let exclusiveToVendorID; if (typeof exclusiveToSpecificVendor === &q
const exclusiveToSpecificVendor = $("#VendorList").data("kendoComboBox");
let exclusiveToVendorID;
if (typeof exclusiveToSpecificVendor === "object") {
// This line below is the culprit
if (typeof exclusiveToSpecificVendor.dataItem(exclusiveToSpecificVendor.select()) === "undefined") {
exclusiveToVendorID = null;
}
else {
exclusiveToVendorID = exclusiveToSpecificVendor.dataItem(exclusiveToSpecificVendor.select()).VendorID;
}
}
else {
exclusiveToVendorID = null;
}