So i have a lot of states I need to set based on multiple objects presence and states:
At the moment I'm just doing a classic if statement and then checking against undefined.
let show_x = false;
if (some_object_presence !== 'undefined' || some_other_object_presence !== 'undefined' || some.other.object_presence !== 'undefined' ) {
show_x = true;
}
...
This seems like a really long way to do it. Is there a shorthand version I can set like this:
let show_y = some_object_presence || some_other_object_presence || some.other.object_presence;
I need the state of show_y to be a boolean value. I did think about creating intermediate tests for each of the object states I'm looking for but that might just make it complicated again eg.
let some_object_presence = object_qwe ? true : false;
let some_other_object_presence = object_asd ? true : false;
let some_third_object_presence = object_zxc ? true : false;
let show_z = some_object_presence || some_other_object_presence || some_third_object_presence;
Any ideas would be helpful
Aucun commentaire:
Enregistrer un commentaire