I don't understand the behavior I have in my condition. I try to reduce the code as much as possible.
With this condition I want to know if r.user.id
or r.user.uid
is equal to getUser.uid
.
https://jsbin.com/zakofusiga/edit?js,console
let getUser = { uid: "123" };
let r = { user: { id: "toto", uid: "123"}}
if (r.user && (r.user?.id === getUser?.uid || r.user?.uid === getUser?.uid)) { ... }
To do so I made this code so below. It works but I don't understand why r?.user?.id||uid === getUser?.uid
me returns toto
is not a boolean. Does this code work like the one above?
if (r?.user?.id||uid === getUser?.uid) {
console.log("test 1", r?.user?.id||uid === getUser?.uid);
}
if (r.user?.id === getUser?.uid) {
console.log("test 2");
}
if (r.user?.uid === getUser?.uid) {
console.log("test 3");
}