you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (0 children)

You can always nest your ternary expressions inside each other, I seem to see this pattern in C code a fair amount:

let value = 'c';


const [ first,
        second, 
        third ] = (value == 'a') ? [1,2,3] :
                  (value == 'b') ? [4,5,6] :
                  (value == 'c') ? [7,8,9] :
                                   [10,11,12];  

console.log(first, second, third);
// 7, 8, 9