Bitwise Not operator
The bitwise NOT is represented by a tilde (~) The bitwise NOT returns the one's complement of the number.
<!DOCTYPE html>
<html>
<head>
<title>Operator Example</title>
<script type="text/javascript">
var num1 = 2;
var num2 = ~num1;
document.writeln(num2); // -3
</script>
</head>
<body>
</body>
</html>
The effect of the bitwise NOT: it negates the number and subtracts 1.
Home
JavaScript Book
Language Basics
JavaScript Book
Language Basics
Operators:
- JavaScript Operators
- Increment/Decrement Operators
- Increment/Decrement Operators for String, Boolean, Floating-point and Object
- Unary Plus and Minus
- Bitwise Not operator
- Bitwise AND
- Bitwise OR
- Bitwise XOR
- Left Shift
- Signed Right Shift
- Unsigned Right Shift
- Logical NOT
- Logical AND
- Logical OR
- Multiply
- Divide
- Modulus
- Add
- Subtract
- Relational Operators
- Equal and Not Equal
- Identically Equal and Not Identically Equal
- Conditional Operator
- Assignment Operators
- Comma Operator