The use of the triple exclamation mark

前端 未结 5 834
眼角桃花
眼角桃花 2020-12-01 05:52

Looking through the source code of one of our projects, I\'ve found some amount of places where we\'re using three exclamation marks in conditional statements, like so:

5条回答
  •  生来不讨喜
    2020-12-01 06:43

    The first double exclamation marks turned to a boolean value any falsy value of the object (undefined, null, 0) or any truthy value, then the third one negates it.

提交回复
热议问题