In Javascript, what would be the best way to evaluate several conditions when taking into consideration variables that could be undefined? For instance, I want to evaluate if x > y only if x is NOT undefined (has a value), and if it is undefined, continue to proceed to the next condition.
Something like:
if(x && x > y && a && a > b && c < d && e > f) ....
Here I want to see if x is defined, and then evaluate if x is greater than y, then go to evaluate if a is defined and evaluate if a is greater than b, then evaluate if c is less than d and etc. So here I want it so that if x or a is undefined CONTINUE to proceed to evaluate c < d and e > f
Here if the variables are are undefined then the whole statement is all false... what are some solutions for this that's clean?
Aucun commentaire:
Enregistrer un commentaire