In Javascript, is it OK to put the ternary operator's `?` on then next line?

后端 未结 4 1354
深忆病人
深忆病人 2021-02-01 15:08

I really like aligning the ? and the : of my ternary operator when they don\'t fit on a line, like this:

var myVar = (condition
    ? ifTrue
    : ifFalse
);
         


        
4条回答
  •  旧巷少年郎
    2021-02-01 15:43

    You should put the operator on the end of the line. That way its more clear that the statment continued to the next line.

提交回复
热议问题