The JS operator generally contains:
1 Arithmetic operators
2 equality operators
3 Relational operators
4 string operators
5 logical operators
6-bit operators
7 Assignment operators
First look at the arithmetic operator, which usually has (+,-,*,/,%,++,--)
Here, the% modulo operator, in fact, is the meaning of the remainder, for example, 5%2=1;
Here's a special talk about + +, and--(here is just the same as ++,--).
1 var i = 1; 2 var j = ++i; // The actual equivalent of i+=1;j=i; 3 Alert (i + "" + j); 4 5 var m = 1; 6 var n = m++; // the actual operation is equivalent to n=m;m+=1; 7 Alert (M + "" + N);
Equality operators, which are typically used to compare two of values.
He is divided into equality operators, as well as equivalent operators.
The equality operator (= =), which is a comparison of two values, is equal and does not compare their type. ("1" ==true, this is equal, because "1" is converted to the number 1, and 1 is true)
The equivalent operator (= = =), which compares the values of both of them for equality, and compares their types, if the object array function is compared, is a comparison reference. ("1" ===1, this is false, because of two types)
Inequality operator (! =), different operator (! = =) Just the opposite of them.
The relational operator.
Comparison operators: (<,>,<=,>=) here is greater than less than the said, <= is not more than the actual, >= is not less than, is not dependent on the equality operator calculation
In operator: The in operator requires a string to the left, an object or an array to the right, or true if the left side is the property name of the right object, or the value of the array.
var p={x:1,y:2};
var q= "x" in P; Returns True
var w= "Y" in P; Returns True
The left side of the instanceof operator is an object, and to the right is the type of an object that is used to determine the object type.
var a=[1,2,3];
a instanceof Array; Returns True
String operators:
Operator (+), which is equivalent to connecting two strings.
var a= "Hello", b= "Qwer";
A+b//Is Helloqwer
The <,<=,>,>= operator, used for strings, is used to determine their order, using alphabetical order.
Logical operators: Commonly used if, while, for statements.
Logic and (&&)
if (a==1&&b==2) {return true}
&& returns True if both sides are true, or False if one is false, without executing the statement.
Logical OR Operator: (| | )
if (a==1| | b==2) {return true}
|| The statement is not executed when both sides return true if only one condition satisfies, and two is false.
Logical NON (! )
It is quite an inverse, if a is true, then! A is false.
Bitwise operator, which is an operation on the binary. JS with a relatively small, here does not elaborate
Assignment operators:
A+=b//equivalent to A=a+b
A-=b//equivalent to A=a-b
This is a pattern +-*/.....
And finally there's a ternary operator? :
eg:x>0?x*y:-x*y;
The equivalent of a judgment, x>0 true to execute x*y, and False to execute-x*y.