我想检查一个嵌套对象中的空值,我将如何循环通过嵌套的属性?通过嵌套对象属性循环
for (var propt in updatedInputs) {
if (updatedInputs[propt] == "") this.cancelSubmit();
// check for nested properties
if (updatedInputs.hasOwnProperty(propt)) {
// loop through nested properties here
}
}
样本对象:
Object {contacts: Array[5]}
contacts: Array[5]
0: "04354355"
1: "24349878779"
2: "wqewqewqeqw"
3: "wqewqeqwe"
4: ""
请给出样本对象 –
你是说如果其中一个嵌套属性是一个数组或对象? –
该示例对象不是有效的js对象,语法错误。此外,你是否试图循环通过嵌套数组或嵌套对象? – nem035