1.CMAScript operator
Arithmetic operators
Increment (+ +), decrement (--)
var i=15; Console.log (i++); Console.log (i); var i1=15; Console.log (++I1); Console.log (I1);
>>
i++: Reference after assignment ++i: first assigned value
NaN: A special value that belongs to a number type that does not get results when the data involved is converted to numbers.
All operations that Nan participates in are false, except! =
var d= "Hello"; var a=+d; Console.log (a); Console.log (typeof a);
>>
logical operators
The operator of the logical AND operation (&&) can be of any type, not just a Boolean value.
If an operand is not the original Boolean value, the logical AND operation does not necessarily return a Boolean value;
- Returns null if one of the operands is null.
- If an operand is Nan, a nan is returned.
- If one of the operands is undefined, return to undefined.
The logical OR operator (| | | Similar to the logical AND operator, a logical OR operation does not necessarily return a Boolean value if an operand is not a Boolean value
Assignment operators
Assigned value =
In JavaScript = delegate assignment, two equals = = to determine equality
For example, x=1 indicates that x is assigned a value of 1
if (x==1) {...} The program indicates that when x is equal to 1
if (x== "on") {...} The program indicates that when x is equal to "on"
Simplified expressions that are formed with other operators
For example i+=1 equivalent to i=i+1,x&=y equivalent to X=x&y
Equal-sex operators
The rules for performing type conversions are as follows:
If one of the operands is a Boolean value, convert it to a numeric value before checking for equality. False converts to 0,true to 1.
If one operand is a string and the other is a number, try converting the string to a number before checking for equality.
If one operand is an object and the other is a string, try to convert the object to a string before checking for equality.
If one operand is an object and the other is a number, try converting the object to a number before checking for equality.
The operator also adheres to the following rules when comparing:
The value null and undefined are equal.
When checking for equality, null and undefined cannot be converted to other values.
If an operand is NaN, the equal sign returns false, and the non-equal sign returns TRUE.
If the two operands are objects, then their reference values are compared. If two operands point to the same object, then the equals sign returns TRUE, otherwise two operands are not equal.
Relational operators
On both sides of the comparison operator if one is a numeric type and one is a different type, its type is converted to a numeric type.
If both sides of the comparison operator are string types, the highest-bit ASC code is compared, and if the highest bit is equal, the second-bit comparison continues.
Boolean operator
Full Equals and non-full equals
equals and non-equal operators are all equal and non-full equals. The two operators do the same as equals and non-equals, except that they do not perform type conversions until they are checked for equality.
JS Basic Learning 2