DEV Community

Discussion on: Vanilla JavaScript String to Number

 
rrdlpl profile image
R • Edited

it's the NOT bitwise operator. It changes the 1 by 0 and 0 by 1. In that example, he is doing it twice.

~ 5 => ~0101 => 1010
~~5 => ~(~0101) => ~(1010) => 0101 => 5

w3schools.com/js/js_operators.asp