比较版本

运算符

修订版 255438:

由 Andyyard 在 进行的修订 255438

修订版 227430:

由 Andyyard 在 进行的修订 227430

标题:
运算符
运算符
网址缩略名:
Core_JavaScript_1.5_Guide/运算符
Core_JavaScript_1.5_Guide/运算符
内容:

修订版 255438
修订版 227430
t7    <h3 id=".E8.BF.90.E7.AE.97.E7.AC.A6" name=".E8.BF.90.E7.AE.97t
>.E7.AC.A6"> 
8      运算符
9    </h3>
10    <p>
11      JavaScript has the following types of operators. This secti
>on describes the operators and contains information about operato 
>r precedence. 
12    </p>
13    <ul>
14      <li>
15        <a href="cn/Core_JavaScript_1.5_Guide/Operators/Assignmen
>t_Operators">Assignment Operators</a> 
16      </li>
17      <li>
18        <a href="cn/Core_JavaScript_1.5_Guide/Operators/Compariso
>n_Operators">Comparison Operators</a> 
19      </li>
20      <li>
21        <a href="cn/Core_JavaScript_1.5_Guide/Operators/Arithmeti
>c_Operators">Arithmetic Operators</a> 
22      </li>
23      <li>
24        <a href="cn/Core_JavaScript_1.5_Guide/Operators/Bitwise_O
>perators">Bitwise Operators</a> 
25      </li>
26      <li>
27        <a href="cn/Core_JavaScript_1.5_Guide/Operators/Logical_O
>perators">Logical Operators</a> 
28      </li>
29      <li>
30        <a href="cn/Core_JavaScript_1.5_Guide/Operators/String_Op
>erators">String Operators</a> 
31      </li>
32      <li>
33        <a href="cn/Core_JavaScript_1.5_Guide/Operators/Special_O
>perators">Special Operators</a> 
34      </li>
35    </ul>
36    <p>
37      JavaScript has both binary and unary operators, and one spe
>cial ternary operator, the conditional operator. A binary operato 
>r requires two operands, one before the operator and one after th 
>e operator: 
38    </p>
39    <pre>
40operand1 operator operand2
41</pre>
42    <p>
43      For example, <code>3+4</code> or <code>x*y</code>.
44    </p>
45    <p>
46      A unary operator requires a single operand, either before o
>r after the operator: 
47    </p>
48    <pre>
49operator operand
50</pre>
51    <p>
52      or
53    </p>
54    <pre>
55operand operator
56</pre>
57    <p>
58      For example, <code>x++</code> or <code>++x</code>.
59    </p>
60    <h4 id=".E8.BF.90.E7.AE.97.E7.AC.A6.E7.9A.84.E4.BC.98.E5.85.8
>8.E7.BA.A7" name=".E8.BF.90.E7.AE.97.E7.AC.A6.E7.9A.84.E4.BC.98.E 
>5.85.88.E7.BA.A7"> 
61      运算符的优先级
62    </h4>
63    <p>
64      <small><i>In accordance with <a href="Talk:cn/Core_JavaScri
>pt_1.5_Guide/Operators#Precedence_Table">relevant discussion</a>, 
> this table was reversed to list operators in <b>decreasing</b> o 
>rder of priority.</i></small> 
65    </p>
66    <table class="fullwidth-table">
67      <tbody>
68        <tr>
69          <th>
70            Operator type
71          </th>
72          <th>
73            Individual operators
74          </th>
75        </tr>
76        <tr>
77          <td>
78            member
79          </td>
80          <td>
81            . &nbsp;[]
82          </td>
83        </tr>
84        <tr>
85          <td>
86            call / create instance
87          </td>
88          <td>
89            () &nbsp;new
90          </td>
91        </tr>
92        <tr>
93          <td>
94            negation/increment
95          </td>
96          <td>
97            ! &nbsp;~ &nbsp;- &nbsp;+ &nbsp;++ &nbsp;-- &nbsp;typ
>eof &nbsp;void &nbsp;delete 
98          </td>
99        </tr>
100        <tr>
101          <td>
102            multiply/divide
103          </td>
104          <td>
105            * &nbsp;/ &nbsp;%
106          </td>
107        </tr>
108        <tr>
109          <td>
110            addition/subtraction
111          </td>
112          <td>
113            + &nbsp;-
114          </td>
115        </tr>
116        <tr>
117          <td>
118            bitwise shift
119          </td>
120          <td>
121            &lt;&lt; &nbsp;&gt;&gt; &nbsp;&gt;&gt;&gt;
122          </td>
123        </tr>
124        <tr>
125          <td>
126            relational
127          </td>
128          <td>
129            &lt; &nbsp;&lt;= &nbsp;&gt; &nbsp;&gt;= &nbsp;in &nbs
>p;instanceof 
130          </td>
131        </tr>
132        <tr>
133          <td>
134            equality
135          </td>
136          <td>
137            == &nbsp;!= &nbsp;=== &nbsp;!==
138          </td>
139        </tr>
140        <tr>
141          <td>
142            bitwise-and
143          </td>
144          <td>
145            &amp;
146          </td>
147        </tr>
148        <tr>
149          <td>
150            bitwise-xor
151          </td>
152          <td>
153            ^
154          </td>
155        </tr>
156        <tr>
157          <td>
158            bitwise-or
159          </td>
160          <td>
161            |
162          </td>
163        </tr>
164        <tr>
165          <td>
166            logical-and
167          </td>
168          <td>
169            &amp;&amp;
170          </td>
171        </tr>
172        <tr>
173          <td>
174            logical-or
175          </td>
176          <td>
177            ||
178          </td>
179        </tr>
180        <tr>
181          <td>
182            conditional
183          </td>
184          <td>
185            ?:
186          </td>
187        </tr>
188        <tr>
189          <td>
190            assignment
191          </td>
192          <td>
193            = &nbsp;+= &nbsp;-= &nbsp;*= &nbsp;/= &nbsp;%= &nbsp;
>&lt;&lt;= &nbsp;&gt;&gt;= &nbsp;&gt;&gt;&gt;= &nbsp;&amp;= &nbsp; 
>^= &nbsp;|= 
194          </td>
195        </tr>
196        <tr>
197          <td>
198            comma
199          </td>
200          <td>
201            ,
202          </td>
203        </tr>
204      </tbody>
205    </table>
206    <p>
207      <small><b>Table 3.1: Operator precedence</b></small>
208    </p>
209    <p>
210      A more detailed version of this table, complete with links 
>to additional details about each operator, may be found in <a hre 
>f="cn/Core_JavaScript_1.5_Reference/Operators/Operator_Precedence 
>#Table">the Reference section</a>. 
211    </p>
212    <p>
213      {{ PreviousNext("Core_JavaScript_1.5_Guide:表达式", "Core_Java
>Script_1.5_Guide:Operators:Assignment_Operators") }} 
214    </p>
215    <hr>
216    <p>
217      --<a href="User:Andyyard">AndyYard</a> 06:23 2007年11月11日 (P
>ST) 
218    </p>

返回历史