我只是想在插入对象之前检查 atext和input 是否不为空。date如果它们都是空的,我希望它们不要添加到其中。然而,我所做的任何尝试,它们仍然被添加到没有任何价值的对象中。
for(let i = 0; i < otherDeps.length; i++) {
let obj;
if(otherDeps[i].name && otherDeps[i].dob != "") { //Here
obj = {
name: otherDeps[i].value,
dob: otherDepsAge[i].value
};
}
otherDepsArray.push(obj);
}
我已经尝试过了if(!otherDeps[i].date),ìf(otherDeps[i]name != '' && otherDeps[i].date != '0000-00-00')
有人知道解决这个问题的正确方法吗?
忽然笑
慕运维8079593
相关分类