How to avoid 'cannot read property of undefined' errors?

前端 未结 16 2202
野性不改
野性不改 2020-11-22 06:02

In my code, I deal with an array that has some entries with many objects nested inside one another, where as some do not. It looks something like the following:



        
16条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 06:38

    I use undefsafe religiously. It tests each level down into your object until it either gets the value you asked for, or it returns "undefined". But never errors.

提交回复
热议问题