解析物产链并评估价值的方法

时间:2019-06-06 19:27:18

标签: javascript

JavaScript中是否有范例或实用程序方法,可让您解析对象属性链

archive[5].school['sir edward high school'].faculties[2].name

然后安全地评估name的值,而不必验证过程的每一步

if(archive[5] && archive[5].school['sir edward high school'] && archive[5].school['sir edward high school'].faculties[2] && archive[5].school['sir edward high school'].faculties[2].name == 'Henry') {
    ...
}

0 个答案:

没有答案