what does these two wavy lines means in cookies chapter?
xr opened this issue · comments
var n = ~~this.cookies.get('view', { signed: true }) + 1;
what does ~~ mean ? thanks
UPDATED:
I searched, they are double-bitwise NOT operation, the following are some paris.
~~null; // => 0
~~undefined; // => 0
~~0; // => 0
~~{}; // => 0
~~[]; // => 0
~~(1/0); // => 0
~~false; // => 0
~~true; // => 1
~~1.2543; // => 1
~~4.9; // => 4
~~(-2.999); // => -2
Due to this.cookies.get('view', { signed: true }) is undefined when first time request to '/', so , in ~~ this way quickly transfer undefined to 0 and increase it...