🔰double tilde (~~)
JS ⟩ statement ⟩ expression ⟩ operator ⟩ double tilde (~~)
nearest integer towards 0.
// ⭐️ ~~(x) : nearest integer towards 0
~~(-5.5) // -5
~~( 5.5) // 5
+undefined // ⭐️ NaN
~~undefined // ⭐️ 0
// similar operators
!!x // any -> bool
+x // any -> number
💡 it's not really an operator, it's just ~~x === ~(~x)
.
➕ bitwise operator ⟩ bitwise not (~) - invert bits.
➕ unary arithmetic operator ⟩ unary plus (+)
➕ unary logical operator ⟩ logical not (!)
Last updated
Was this helpful?