我需要检查状态是否已批准,因此如果为空,我会对其进行检查。什么是最有效的方法?
{
"id": 2,
"email": "yeah@yahoo.com",
"approved": {
"approved_at": "2020"
},
"verified": {
"verified_at": "2020"
}
}
代码
const checkIfEmpty = (user) => {
if (Object.entries(user.verified).length === 0) {
return true;
}
return false;
};