One, bitwise operators
In general applications, we basically use an operator that is not in place. Although, it is based on the underlying, performance and speed will be very good, and that is because the lower level, the use of the difficulty is also very large, the underlying operation is converted to binary operation.
There are seven bitwise operators, namely, bit non-not (~), Bit and and (&), bit or OR (|), bitwise XOR (^), left Shift (<<), signed right Shift (>>), unsigned Right shift (>>>).
var // -26 var // 1 var // - var // $ var // 6 var // 6
Second, assignment operator
The assignment operator is denoted by the equals sign (=), which assigns the right value to the left variable.
var // assign 100 to the box variable
The compound assignment operator is represented by a x=, and X represents an arithmetic operator and a bitwise operator.
var box =200, self-added
This situation can be rewritten as:
var box =+//200,+= instead of box+100
In addition to this + = Plus/assignment operator, there are several others as follows:
1. Multiply/assign (*=)
2. Addition/Assignment (/=)
3. Mold/Fu (%=)
4. Add/assign (+ =)
5. Subtract/assign (-=)
6. Shift Left/assign (<<=)
7. Signed Right Shift/Assignment (>>=)
8. No sign with shift/Assignment (>>>=)
Third, other operators
1. String operator: Only one, that is: "+". Its purpose is to add two strings. Rule: At least one operand is a string.
var // 100100 var // 100100 var // $
2. Comma operator: You can perform multiple operations in a single statement.
var box = +, age = 178, height = +; // multiple variable declarations var box = (1,2,3,4,5); // 5, variable declaration, assigning the last value to a variable, not commonly used var box = [1,2,3,4,5]; // [1,2,3,4,5], the literal declaration of an array var box = { //[Object Object], object literal declaration 1:2, 3:4< c13>, 5:6 };
Four or three-tuple operator:
is actually the shorthand form of the IF statement.
var box = 5 > 4? ' Yes ': ' wrong '; // Yes, 5>4 returns true to assign ' pair ' to box, and vice versa.
Equivalent:
var // Initialize Variables if (5 > 4) { // judgment expression return value box = ' yes '; // Assign Value Else // assignment }
Four, operator precedence
In a general operation, we do not have to take into account the precedence of operators, because we can solve this problem by using parentheses. Like what:
var // -27 var // 8
However, if you do not use parentheses to enforce precedence, we must follow the following order:
JavaScript bitwise operators, assignment operators, other operators, ternary operators, operator precedence