DEV Community

Discussion on: 5 Programming Patterns I Like

Collapse
 
erenyatkin profile image
Ahmet Eren Yatkın

I love nested ternaries, shortens the code. A real world example, simple Vue-router meta controlling;

    const accessControl =
      to.meta.abKey === 'default'
        ? true
        : to.matched.filter(x => abKeys.includes(x.meta.abKey)).length > 0
        ? true
        : false;
Collapse
 
guico33 profile image
guico33

cond1 ? true : cond2 ? true : false

is the same as

cond1 || cond2