The use of the triple exclamation mark

前端 未结 5 836
眼角桃花
眼角桃花 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:21

    In javascript, it's a way to show that what you are evaluating is not a boolean but a truthy or falshy.

    So for truthy/falshy values you either use !! or !!! and for booleans ! or nothing.

    This is simply for readability.

提交回复
热议问题