• JAVASCRIPT > les tests, if, else

      L’opérateur !!

      C’est un raccourci pour boolean(), qui convertit ce qui suit en une valeur bolléenne.

      !!0false

      !!nullfalse

      !!undefinedfalse

      !!48true

      !!“hello” true

      !![1, 2, 3]true

       

      (!!) is actually the not (!) operator twice :

      - The first not operator converts the object to an inverted boolean value.

      - The second not operator inverts the inverted boolean value. In other words, this makes it the real boolean value of the object.

      True et False

      false

      false, 0, -0, 0n (BigInt zero), , “”, , null, undefined, NaN

      True

      true, [0, 0, 0], "toto", 15

       

 

Aucun commentaire

 

Laissez un commentaire