Two\'s complement method - generates -(x + 1).
-(x + 1)
for example when JavaScript encounters the Tilde he uses this method:
~5 = -(5+1) = -6
~5 = -(5 + 1) = -6
so far so good. However, ~ is not the two's complement, it's the binary inversion operator.
~
5 = 0000 0101 flip : 1111 1010
which is -6
does that make it clear?