JavaScript Internals (521 Qs)•Part 6: Async Internals, Memory, Microtasks & Web APIs (329 - 403)
What is the purpose of double tilde operator
The double tilde operator(~~) is known as double NOT bitwise operator. This operator is a slightly quicker substitute for Math.floor().
Practical Code Example
javascript
// Double Tilde (~~) Operator: Fast bitwise shortcut for Math.trunc():
console.log(~~4.9); // 4
console.log(~~-4.9); // -4
console.log(~~"42"); // 42 (also coerces numeric strings)