What does it mean "return !! userId"

This question already has an answer here:

  • What is the !! (not not) operator in JavaScript? 31 answers

  • 它返回userId作为boolean


    It's a boolean cast, from a fasly or truethy value to false or true respectively.

    You might see:

    var string = ""; // empty string is falsy
    var bool = !!string; // false
    

    falsy by the way means that it follows: myvar == false as opposed to false which follows: myvar === false (triple comparison).

    Similarly truethy is myvar == true .


    !!userIdBoolean(userId)相同。

    链接地址: http://www.djcxy.com/p/12666.html

    上一篇: 你最喜欢的C ++编码风格成语是什么?

    下一篇: 这是什么意思“return !! userId”