Remembering the Ternary Operator Syntax

后端 未结 7 1759
误落风尘
误落风尘 2021-01-05 08:11

Anyone have a good trick to remember the standard ternary syntax?

Specifically whether the \'?\' or \':\' comes first. I have consistently gotten this backwards over

7条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 08:17

    It goes like this:

    myVariable = this.testMethod() ? 'value for true case' : 'value for false case'
    

提交回复
热议问题