Javascript AND operator within assignment

后端 未结 6 698
滥情空心
滥情空心 2020-11-22 05:20

I know that in JavaScript you can do:

var oneOrTheOther = someOtherVar || \"these are not the droids you are looking for...\";

where the va

6条回答
  •  渐次进展
    2020-11-22 05:38

    && is sometimes called a guard operator.

    variable = indicator && value
    

    it can be used to set the value only if the indicator is truthy.

提交回复
热议问题