Home > front end >  JavaScript operator
JavaScript operator

Time:09-21

1. The JavaScript operator:
(1) the arithmetic operators: + - */%
+ add
The two values can be add operation, if is two strings of string concatenation
Any value and string do add operation, will be converted to a string first, and then and string concatenation operation
Can also be done through the "+" implicit conversion,
- minus
To subtract the two values, the result and return
* take
To multiplication, the two values and returns the result
/in addition to the
Can to division of two values, the result and return
% modulus
Modulus algorithm (modulo)
+ + on the
For example: i++=I + 1;
- the decrement
For example: I -=I - 1;

(2) the relationship between operator:
<>=& lt;======not strict strict!=not strictly before
(3) logical operators
& & Logic - and - and
| | - logic or - or
! Non - logic - take anti - take a
(4) the assignment operator
JavaScript assignment operators
=assignment operator
+=
Num + 2==& gt; Equivalent to the num=num + 2;
*=
Num -=2=& gt; Equivalent to the num=num - 2;
/=
Num/2==& gt; Equivalent to the num=num/2;
%=
Num %=2=& gt; Equivalent to the num=num % 2;
(5) conditional operator
Unary operator, the operator only need one operand can operation symbols + + -
Binary operators: the operator need two operands can operation,
Conditional operator is also called the ternary operator
Grammar: conditional expression? Statement 1:2;
Perform process:
Conditional operator at execution time, first of all, the expression is evaluated,
If the value is true, execute the statement 1, and returns the results
If the value is false, execute the statement 2, and returns the results

Composite operator: +=-=*=/=%=
2. The relationship between arithmetic expressions:
Expression of linked by relational operators
Relationship between the results of the computation expression is a Boolean type: true or false
For example:
Expression expression 1 | | 2
If a is true, the result is true
! The expression 1
Expression is 1 the result is true, the entire result to false
Expression is 1 the result is false, the result is true


CodePudding user response:

  • Related