JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

4.7 Operator Overview

4.7 Operator Overview

Operators are used for JavaScript’s arithmetic expressions, comparison expressions, logical expressions, assignment expressions, and more. Table 4-1 summarizes the operators and serves as a convenient reference.

Note that most operators are represented by punctuation characters such as + and =. Some, however, are represented by keywords such as delete and instanceof. Keyword operators are regular operators, just like those expressed with punctuation; they simply have a less succinct syntax.

Table 4-1 is organized by operator precedence. The operators listed first have higher precedence than those listed last. Operators separated by a horizontal line have different precedence levels. The column labeled A gives the operator associativity, which can be L (left-to-right) or R (right-to-left), and the column N specifies the number of operands. The column labeled Types lists the expected types of the operands and (after the symbol) the result type for the operator. The subsections that follow the table explain the concepts of precedence, associativity, and operand type. The operators themselves are individually documented following that discussion.

Table 4-1. JavaScript operators

Operator Operation A N Types
++ Pre- or post-increment R 1 lvalnum
- Pre- or post-decrement R 1 lvalnum
- Negate number R 1 numnum
+ Convert to number R 1 numnum
~ Invert bits R 1 intint
! Invert boolean value R 1 boolbool
Operator Operation A N Types
delete Remove a property R 1 lvalbool
typeof Determine type of operand R 1 anystr
void Return undefined value R 1 anyundef
*, /, % Multiply, divide, remainder L 2 num,numnum
+, Add, subtract L 2 num,numnum
+ Concatenate strings L 2 str,strstr
<< Shift left L 2 int,intint
>> Shift right with sign extension L 2 int,intint
>>> Shift right with zero extension L 2 int,intint
<, <=,>, >= Compare in numeric order L 2 num,numbool
<, <=,>, >= Compare in alphabetic order L 2 str,strbool
instanceof Test object class L 2 obj,funcbool
in Test whether property exists L 2 str,objbool
== Test for equality L 2 any,anybool
!= Test for inequality L 2 any,anybool
=== Test for strict equality L 2 any,anybool
!== Test for strict inequality L 2 any,anybool
& Compute bitwise AND L 2 int,intint
^ Compute bitwise XOR L 2 int,intint
| Compute bitwise OR L 2 int,intint
&& Compute logical AND L 2 any,anyany
|| Compute logical OR L 2 any,anyany
?: Choose 2nd or 3rd operand R 3 bool,any,anyany
= Assign to a variable or property R 2 lval,anyany
*=, /=, %=, +=, Operate and assign R 2 lval,anyany
-=, &=, ^=, |=,
<<=, >>=, >>>=
, Discard 1st operand, return second L 2 any,anyany
友情链接It题库(| 版权归yishouce.com所有| 友链等可联系|粤ICP备16001685号-1