?? ops.html
字號:
<HTML><HEAD> <META NAME="keywords" CONTENT="electronic commerce, ecommerce, ebusiness, e-business, e-commerce, enterprise software, net economy, Netscape, Sun Microsystems, Sun-Netscape Alliance, iPlanet, internet software"> <META NAME="description" CONTENT="The Sun-Netscape Alliance, a strategic alliance formed by America Online and Sun Microsystems, Inc., is delivering iPlanet e-commerce software and enterprise solutions that enable companies to compete successfully in the Net Economy"> <META HTTP-EQUIV="Content-Type" content="text/html; charset=ISO-8859-1"> <META NAME="TEMPLATEBASE" CONTENT="Authored in FrameMaker. Converted to HTML in WebWorks Publisher 2000. manual wdt 1.5"> <META NAME="LASTUPDATED" CONTENT="09/28/00 13:16:21"> <TITLE> Core JavaScript Reference 1.5: 5 Operators</TITLE></HEAD><BODY TEXT="#000000" LINK="#666699" VLINK="#666699" ALINK="#333366" BGCOLOR="#FFFFFF"><MAINCONTENT><NAVIGATIONCONTENT> <TABLE WIDTH="100%" BORDER="0" CELLSPACING="4"> <TR> <TD VALIGN="TOP"> <b><a href="comment.htm"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Previous</a></FONT> </b><a href="contents.htm"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Contents</a></FONT></b> <a href="ix.htm"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Index</a></FONT></b> <a href="partjava.htm"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Next</a></FONT></b> </TD> </TR> <TR> <TD VALIGN="TOP" ALIGN="RIGHT" BGCOLOR="#CCCCCC"> <FONT FACE="Arial, Helvetica, sans-serif" COLOR="#000000" SIZE="2"><B> Core JavaScript Reference 1.5</B></FONT> </TD> </TR> <TR> </TABLE> <BR></NAVIGATIONCONTENT><BOOKCONTENT> <blockquote><BR><BR> <A NAME="1005816"> </A><A NAME=""> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="4" COLOR="#666666"><B><zchapnumber>Chapter 5 </zchapnumber> </B></FONT><A NAME="1003191"> </A><A NAME="Operators"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="4" COLOR="#000000"><B><zchaptitle>Chapter 5 Operators</zchaptitle></B></FONT><BR><BR><BR><A NAME="1056211"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>JavaScript has assignment, comparison, arithmetic, bitwise, logical, string, and special operators. This chapter describes the operators and contains information about operator precedence.</zparagraph></FONT><P><A NAME="1056212"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The following table summarizes the JavaScript operators.</zparagraph></FONT><P><P><A NAME="1056548"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0"> <CAPTION></CAPTION><P><FONT FACE=""><B><A NAME="1065828"> </A><A NAME="JavaScript operators. "> </A><ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><ztablecaption>Table 5.1    JavaScript operators. </ztablecaption></B></FONT></B></FONT><BR><BR> <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1065834"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><ztablehead>Operator category</ztablehead></B></FONT></TH> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1065836"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><ztablehead>Operator</ztablehead></B></FONT></TH> <TH VALIGN=TOP ALIGN=LEFT><A NAME="1065838"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><ztablehead>Description</ztablehead></B></FONT></TH> </DIV></TR> <TR> <TD VALIGN=TOP COLSPAN=1 ROWSPAN=7><P><A NAME="1065842"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext><A HREF="ops.html#1042400" >Arithmetic Operators</A></ztabletext></FONT></TD> <TD VALIGN=TOP><A NAME="1065845"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>+</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065847"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>(Addition) Adds 2 numbers.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065851"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>++</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065853"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>(Increment) Adds one to a variable representing a number (returning either the new or old value of the variable).</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065857"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>-</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065859"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>(Unary negation, subtraction) As a unary operator, negates the value of its argument. As a binary operator, subtracts 2 numbers.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065863"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>--</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065865"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Decrement) Subtracts one from a variable representing a number (returning either the new or old value of the variable).</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065869"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>*</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065871"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Multiplication) Multiplies 2 numbers.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065875"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>/</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065877"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Division) Divides 2 numbers.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065881"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>%</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065883"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Modulus) Computes the integer remainder of dividing 2 numbers.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP COLSPAN=1 ROWSPAN=2><P><A NAME="1065888"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext><A HREF="ops.html#1042582" >String Operators</A></ztabletext></FONT></TD> <TD VALIGN=TOP><P><A NAME="1065890"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>+</ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1065892"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(String addition) Concatenates 2 strings.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><P><A NAME="1065896"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>+=</ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1065898"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>Concatenates 2 strings and assigns the result to the first operand.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP COLSPAN=1 ROWSPAN=3><P><A NAME="1065902"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext><A HREF="ops.html#1044813" >Logical Operators</A></ztabletext></FONT></TD> <TD VALIGN=TOP><P><A NAME="1065905"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>&&</ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1065907"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Logical AND) Returns the first operand if it can be converted to false; otherwise, returns the second operand. Thus, when used with Boolean values, && returns true if both operands are true; otherwise, returns false.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><P><A NAME="1065911"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>||</ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1065913"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Logical OR) Returns the first operand if it can be converted to true; otherwise, returns the second operand. Thus, when used with Boolean values, || returns true if either operand is true; if both are false, returns false.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><P><A NAME="1065917"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>!</ztabletext></FONT> </TD> <TD VALIGN=TOP><P><A NAME="1065919"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Logical NOT) Returns false if its single operand can be converted to true; otherwise, returns true.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP COLSPAN=1 ROWSPAN=7><P><A NAME="1065923"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext><A HREF="ops.html#1042437" >Bitwise Operators</A></ztabletext></FONT></TD> <TD VALIGN=TOP><A NAME="1065926"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>&</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065928"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Bitwise AND) Returns a one in each bit position if bits of both operands are ones.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065932"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>^</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065934"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Bitwise XOR) Returns a one in a bit position if bits of one but not both operands are one.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065938"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>|</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065940"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Bitwise OR) Returns a one in a bit if bits of either operand is one.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065944"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>~</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065946"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Bitwise NOT) Flips the bits of its operand.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065950"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline><<</zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065952"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Left shift) Shifts its first operand in binary representation the number of bits to the left specified in the second operand, shifting in zeros from the right.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065956"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>>></zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065958"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1"><ztabletext>(Sign-propagating right shift) Shifts the first operand in binary representation the number of bits to the right specified in the second operand, discarding bits shifted off.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP><A NAME="1065962"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="-1"><zcodeline>>>></zcodeline></FONT><P> </TD> <TD VALIGN=TOP><P><A NAME="1065964"> </A><ztabletext>(Zero-fill right shift) Shifts the first operand in binary representation the number of bits to the right specified in the second operand, discarding bits shifted off, and shifting in zeros from the left.</ztabletext></FONT> </TD> </TR> <TR> <TD VALIGN=TOP COLSPAN=1 ROWSPAN=12><P><A NAME="1065968"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="-1">
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -