[英]Node.js showing TypeError: Cannot read properties of undefined
RV =(typeof (myresult.CDF.UTILITYTYPE.D2.INSTPARAM[0].VALUE !== 'undefined')) ? myresult.CDF.UTILITYTYPE.D2.INSTPARAM[0].VALUE : 'NA';
in the above code i want to get the value, if the key does not exists it should take 'NA' but iam getting below error在上面的代码中,我想获取值,如果密钥不存在,它应该采用“NA”,但我遇到了以下错误
Error : - TypeError: Cannot read properties of undefined (reading 'INSTPARAM')错误:- TypeError:无法读取未定义的属性(读取“INSTPARAM”)
myresult.CDF.UTILITYTYPE.D2?.INSTPARAM[0].VALUE??我的结果.CDF.UTILITYTYPE.D2?.INSTPARAM[0].VALUE?? 'NA'; '不适用';
using the option chaining.使用选项链。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.