Chapter 3 operators and Expressions
1. Operator
From the formal view, the operator can be either a symbol (such as +,-,*, etc.), or it may be a character (delete,instanceof, etc.);
From a structural perspective, operators can be divided into unary, two, and ternary operators.
There are various implicit conversions with operator manipulation values.
The following table is all operators, from top to bottom priority from high to low, with the same priority in the split line.
1.1 Increment and decrement
Front: Calculate first, then take value;
After: First take the value, after calculation;
1.2-bit operator
Used to manipulate the underlying memory address.
1.3 Boolean operators
A total of three, its priority order is! > && > | |
1.4 Equality operators
Because the equality operator makes a forced type conversion, it has to be compared with the congruent operator.
1.5-piece operator
Boolean-expression? True-value:false-value
1.6 Assignment operators
Assignment operators can be combined with other operators into compound assignment operators.
1.7 comma operator
The comma operator is used to separate multiple expressions, such as to define multiple variables in an assignment statement, and to concatenating multiple assignment expressions with commas.
2. Expression
An expression is a phrase that can be computed by the parser for a value.
"authority" lists 10 types of expressions.
2.1 Original expression
The original expression is the smallest unit of an expression, including constants, variables, direct quantities, and keywords.
2.2 Array and object initialization expressions
Array initialization expression: [A,b,c]
Object initialization expression: {a:a, b:b}
2.3 Function expressions
function () {}
2.4 Property-Access expressions
Expression.identifier
Expression[expression]
The. And [previous expressions are evaluated first, and if the result is not an object or an array, it is converted to an object.
2.5 Function-Call expressions
Foo ()
A.method ()
2.6 Object-Creation expressions
Adding the operator new to the function call expression is an object creation expression. The following parentheses can be omitted.
2.7 Arithmetic expressions
Expressions that contain operators
2.8 Relational Expressions
An expression with comparison operators, including in and instanceof, that returns a Boolean value
2.9 Logical Expressions
An expression that contains a logical operator. Typically used to process a relational expression and return a Boolean value.
If the value computed by the expression of the logical operator operation is not a Boolean value, it is handled by false values (False,undefined,null, ", 0,nan) and True value (values other than false values), as follows:
&&: If the left-hand computed value is false, the left operation result is returned, and the right side is ignored;
If the left-hand computed value is true, the result of the right operation is returned, whether true or false.
|| : If the left computed value is true, the result of the left operation is returned, and the right side is ignored;
If the left-hand computed value is false, the result of the right operation is returned, whether true or false.
! : Always returns a Boolean value.
2.10 Assignment Expressions
An expression with an assignment operator.
Kidney Day Arch A Stroke JavaScript series Chapter3 Operators&expressions