是否有比以下方法更简洁/更短的方法来检查多维数组是否未定义(避免在任何维度出现未定义错误):
if(arr != undefined && arr[d1] != undefined && arr[d1][d2] != undefined){
// arr[d1][d2] isn't undefined
}
如果arr
或arr[d1]
未定义,则执行以下操作将引发错误:
if(arr[d1][d2] != undefined){
// arr[d1][d2] isn't undefined
}