I. arithmetic operators
+: Calculation between the digital and the links between strings
As long as both sides + side is there any time of the string, then the string link
Arithmetic operators, what does?
+ - * / % ++ --
++ / - symbols of usage:
When a prefix to increment / decrement in use
When used as a suffix to the increment / decrement
Priority: First * /% + again - if you want to elevate the priority of use ()
The method of rounding errors solution: .toFixed (n) n represents decimal places reserved
example:
var Change = 2 - 1.6;
Change = change.toFixed (2);
II. Relational operators
> < >= <= == != === !==
The end result must be a boolean relational operator
== determines whether the two data are equal values
! = Not equal, it is determined whether the two data are not equal to the value
=== values and determines whether the type of exactly equal
! == type and determines whether the value is not equal to complete
1.string number and size is determined, the browser will string (string) is implicitly convertible to type a number Number () function
2. Any data is compared with a NaN, the result is false 30a must be converted to NaN
E.g:
console.log('30a'>5); // false NaN > 5
3. Analyzing between the string and comparing it with the unicode string code size of each character
III. Assignment operator
+= -= *= /= %= &= |= ^=
Syntax: a + = b and a = a + b the same effect
Unary operators: ++ -!
Binary operators: + - * /% && || ^ & |> <
Ternary operator:
It requires three operands / Expression Expression 1 Expression 2: Expression 3;?
Expression 1: Operation result should be a boolean
Expression 1 = true executing the expression 2
Expression Expression 1 = false performed 3
Allows nested
IV. Logical Operators
Action: determining a relationship between a plurality of conditions
&&: a number of conditions must be satisfied to see false is false
||: meet one of the conditions is true you can see the true
! Negate
And short-circuit: as long as the first condition is false, the result of the entire expression are false, and the second condition is not to judge
Short circuit or: as long as the first condition is true, the entire expression result is true, and not to judge a second condition
V. Bitwise Operators
Only do digital operations, and want to convert binary numbers, do arithmetic
& :( bitwise) on both sides of the operands converted into binary numbers each, as long as all the time corresponding to 1, which is only 1 bit result, or the result is bit 0
Action: determining a parity, to be higher than the efficiency of the mold
Analyzing the figures do bitwise 1, the last one is even 0 1 odd
E.g:
console.log ((10 & 1) === 0); true even number
console.log ((9 & 1) === 0); false odd
10: 1010 11: 1011
1 : 0001 1 : 0001
--------- --------
0000 0001
Even and odd
| :( bitwise or) on both sides of the operands converted into binary numbers on each compare the two figures is a 1, then the result is 1 bit, otherwise 0
Case (effect): rounding down operation will certainly bit data to binary, the decimal integer will be converted to
E.g:
was num3 = 6.5;
console.log(num3 | 0);
^ :( XOR) on both sides of the digital conversion is compared to binary numbers on each, only one is 1, the result was this bit is 1, otherwise 0
Effect: the exchange value of the two numbers
E.g:
Exchange value of num1 and num2
num1 = num1 ^ num2; - abbreviated --num1 ^ = num2;
num2 = num2 ^ num1; - abbreviated --num2 ^ = num1;
num1 = num1 ^ num2; - abbreviated --num1 ^ = num2;