bitwise not (~)

🚧 under construction -> code example

JSstatementexpressionoperatorarithmeticbitwise ⟩ not

┌── (+x !== ~~x)

│  x           type        +x              ~~x          ~x      ⭐   
────────────────────────────────────────────────────────────────────
   null        Null                    0            0            -1
undefined   Undefined             NaN            0            -1
────────────────────────────────────────────────────────────────────
   true        Boolean                 1            1            -2
   false       Boolean                 0            0            -1
────────────────────────────────────────────────────────────────────
   ''          String                  0            0            -1
   '23'        String                 23           23           -24
'yes'       String                NaN            0            -1
────────────────────────────────────────────────────────────────────
   1           Number                  1            1            -2
   0           Number                  0            0            -1
NaN         Number                NaN            0            -1
Infinity    Number           Infinity            0            -1
-Infinity   Number          -Infinity            0            -1
────────────────────────────────────────────────────────────────────
40n         BigInt          TypeError           40           -41
Symbol()    Symbol          TypeError    TypeError     TypeError
────────────────────────────────────────────────────────────────────
⭐ ({a:1})     Object                NaN            0            -1
⭐ ({})        Object                NaN            0            -1
────────────────────────────────────────────────────────────────────
   []          Array                   0            0            -1
⭐ [4.5]       Array                 4.5            4            -5
⭐ ['-7.8']    Array                -7.8           -7             6
⭐ [1,2,3]     Array                 NaN            0            -1
────────────────────────────────────────────────────────────────────
/regex/     RegExp                NaN            0            -1
new Date    Date        1667543819273   1096508425   -1096508426
⭐ ()=>{}      Function              NaN            0            -1
────────────────────────────────────────────────────────────────────

Last updated

Was this helpful?