in YDKJS types and grammar there is this code snippet:
var a = 42;
var b = "foo";
var c = false;
var d = a && b || c ? c || b ? a : c && b : a;
d; // 42
And the author stated that the correct operation sequence is something like this:
((a && b) || c) ? ((c || b) ? a : (c && b)) : a
I can understand that in JS the operation precedent goes something like this :
&&>|| but what about ? and : ?
do they come together?
For the snippet above I understand the ((a&&b)||c)
part. but why ((c || b) ? a : (c && b))
also could someone give me some more example of how to use conditional/ternary operator?
i dont really get how it works…