javascript shorthand if statement, without the else portion

后端 未结 7 1535
孤街浪徒
孤街浪徒 2020-12-01 07:52

So I\'m using a shorthand javascript if/else statement (I read somewhere they\'re called Ternary statements?)

this.dragHandle.hasClas

7条回答
  •  庸人自扰
    2020-12-01 08:05

    you can use && operator - second operand expression is executed only if first is true

    direction == "right" && slideOffset += $(".range-slide").width()
    

    in my opinion if(conditon) expression is more readable than condition && expression

提交回复
热议问题