?? ops.html
字號:
<TD VALIGN=TOP><P><A NAME="1066168"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>Specifies an expression to be evaluated without returning a value.</ztabletext></FONT> </TD> </TR></TABLE><P></FONT><P><BR><BR><A NAME="1042274"> </A><A NAME="Assignment Operators"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="4"><zhead1>Assignment Operators</zhead1><HR SIZE="2" NOSHADE></FONT><BR><A NAME="1042277"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>An assignment operator assigns a value to its left operand based on the value of its right operand.<BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0"> <CAPTION></CAPTION><P><FONT FACE=""><B></B></FONT><BR><BR> <TR> <TD VALIGN=TOP><P><A NAME="1043621"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext><I>Implemented in</I></ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1043623"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>JavaScript 1.0</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><P><A NAME="1053113"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext><I>ECMA version</I></ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1053115"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>ECMA-262</ztabletext></FONT> </TD> </TR></TABLE><P></zparagraph></FONT><P><A NAME="1043593"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The basic assignment operator is equal (=), which assigns the value of its right operand to its left operand. That is, x = y assigns the value of y to x. The other assignment operators are usually shorthand for standard operations, as shown in the following table.</zparagraph></FONT><P><P><A NAME="1052965"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0"> <CAPTION></CAPTION><P><FONT FACE=""><B><A NAME="1042285"> </A><A NAME="Assignment operators"> </A><ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B><ztablecaption>Table 5.2    Assignment operators</ztablecaption></B></FONT></B></FONT><BR><BR> <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1042289"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B><ztablehead>Shorthand operator </ztablehead></B></FONT></TH> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1042291"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B><ztablehead>Meaning</ztablehead></B></FONT></TH> </DIV></TR> <TR> <TD VALIGN=TOP><A NAME="1042293"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x += y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042295"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x + y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042297"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x -= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042299"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x - y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042301"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x *= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042303"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x * y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042305"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x /= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042307"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x / y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042309"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x %= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042311"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x % y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042313"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x <<= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042315"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x << y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042317"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x >>= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042319"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x >> y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042321"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x >>>= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042323"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x >>> y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042325"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x &= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042327"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x & y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042329"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x ^= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042331"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x ^ y</zcodeline></FONT><P> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1042333"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x |= y</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><A NAME="1042335"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>x = x | y</zcodeline></FONT><P> </TD> </TR></TABLE><P></FONT><P><A NAME="1042338"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>In unusual situations, the assignment operator is not identical to the Meaning expression in <A HREF="ops.html#1042285" >Table 5.2</A>. When the left operand of an assignment operator itself contains an assignment operator, the left operand is evaluated only once. For example:</zparagraph></FONT><P><A NAME="1061038"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>a[i++] += 5 //i is evaluated only once<br>a[i++] = a[i++] + 5 //i is evaluated twice</zcodeline></FONT><P><BR><BR><A NAME="1060974"> </A><A NAME="Comparison Operators"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="4"><zhead1>Comparison Operators</zhead1><HR SIZE="2" NOSHADE></FONT><BR><A NAME="1043854"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A comparison operator compares its operands and returns a logical value based on whether the comparison is true.<BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0"> <CAPTION></CAPTION><P><FONT FACE=""><B></B></FONT><BR><BR> <TR> <TD VALIGN=TOP><P><A NAME="1049975"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext><I>Implemented in</I></ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1049977"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>JavaScript 1.0</ztabletext></FONT><P><A NAME="1052922"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext></ztabletext></FONT><P><A NAME="1050900"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>JavaScript 1.3: Added the <FONT FACE="courier, couriernew, monospaced size">===</FONT> and <FONT FACE="courier, couriernew, monospaced size">!==</FONT> operators.</ztabletext></FONT><P><A NAME="1054717"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext></ztabletext></FONT><P><A NAME="1054718"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>JavaScript 1.4: Deprecated <FONT FACE="courier, couriernew, monospaced size">==</FONT> for comparison of two <FONT FACE="courier, couriernew, monospaced size">JSObject</FONT> objects. Use the <A HREF="lcjsobj.html#1194386" >JSObject.equals</A> method.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><P><A NAME="1053122"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext><I>ECMA version</I></ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1053124"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>ECMA-262 includes all comparison operators except === and !==.<br>ECMA-262 Edition 3 adds === and !==.</ztabletext></FONT> </TD> </TR></TABLE><P></zparagraph></FONT><P><A NAME="1050162"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The operands can be numerical or string values. Strings are compared based on standard lexicographical ordering, using Unicode values.</zparagraph></FONT><P><A NAME="1049688"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>A Boolean value is returned as the result of the comparison.</zparagraph></FONT><P><ul><A NAME="1050116"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B> <li></B><zsmartlist1>Two strings are equal when they have the same sequence of characters, same length, and same characters in corresponding positions.</zsmartlist1></FONT><P><A NAME="1050117"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B> <li></B><zsmartlist1>Two numbers are equal when they are numerically equal (have the same number value). NaN is not equal to anything, including NaN. Positive and negative zeros are equal.</zsmartlist1></FONT><P><A NAME="1050118"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B> <li></B><zsmartlist1>Two objects are equal if they refer to the same Object.</zsmartlist1></FONT><P><A NAME="1050119"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B> <li></B><zsmartlist1>Two Boolean operands are equal if they are both <FONT FACE="courier, couriernew, monospaced size">true</FONT> or <FONT FACE="courier, couriernew, monospaced size">false</FONT>.</zsmartlist1></FONT><P><A NAME="1050647"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B> <li></B><zsmartlist1>Null and Undefined types are == (but not ===).</zsmartlist1></FONT><P></ul><A NAME="1047460"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following table describes the comparison operators.</zparagraph></FONT><P><P><A NAME="1052977"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0"> <CAPTION></CAPTION><P><FONT FACE=""><B><A NAME="1043861"> </A><A NAME="Comparison operators"> </A><ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B><ztablecaption>Table 5.3    Comparison operators</ztablecaption></B></FONT></B></FONT><BR><BR> <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1043867"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B><ztablehead>Operator</ztablehead></B></FONT></TH> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1043869"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><B>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -