⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boolean.html

📁 javascript 1.5规范
💻 HTML
📖 第 1 页 / 共 3 页
字号:
<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:15:13">	<TITLE> Core JavaScript Reference 1.5:  </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="array.html"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Previous</a></FONT>&nbsp;&nbsp;&nbsp;&nbsp;</b><a href="contents.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Contents</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;<a href="ix.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Index</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;<a href="date.html"><b><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2" COLOR="#993300">Next</a></FONT></b>&nbsp;&nbsp;&nbsp;&nbsp;         </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>      <BR><BR><P><A NAME="1193137"> </A><A NAME="Boolean"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="5"><B><zrefhead1>Boolean</zrefhead1></B></FONT><P><A NAME="1193151"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> object is an object wrapper for a boolean value.<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="1193140"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext><I>Core object</I></ztabletext></FONT>&nbsp;</TD>    <TD VALIGN=TOP><P><A NAME="1193142"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext></ztabletext></FONT>&nbsp;</TD>  </TR>  <TR>    <TD VALIGN=TOP><P><A NAME="1193144"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext><I>Implemented in</I></ztabletext></FONT>&nbsp;</TD>    <TD VALIGN=TOP><P><A NAME="1193146"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>JavaScript 1.1, NES 2.0</ztabletext></FONT><P><A NAME="1193627"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext></ztabletext></FONT><P><A NAME="1193150"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>JavaScript 1.3: added <A HREF="boolean.html#1193426"  >toSource</A> method</ztabletext></FONT>&nbsp;</TD>  </TR>  <TR>    <TD VALIGN=TOP><P><A NAME="1193978"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext><I>ECMA version</I></ztabletext></FONT>&nbsp;</TD>    <TD VALIGN=TOP><P><A NAME="1193980"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>ECMA-262</ztabletext></FONT>&nbsp;</TD>  </TR></TABLE><P></zparagraph></FONT><P><BR><A NAME="1193152"> </A><A NAME="Created by"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Created by</zrefheader></B></FONT><BR><A NAME="1193153"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> constructor:</zparagraph></FONT><P><A NAME="1193154"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>new Boolean(<I>value</I>)</zcodeline></FONT><P><BR><A NAME="1193155"> </A><A NAME="Parameters"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Parameters</zrefheader></B></FONT><BR><A NAME="1193161"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><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><A NAME="1193158"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>value</zcodeline></FONT><P>&nbsp;</TD>    <TD VALIGN=TOP><P><A NAME="1193160"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>The initial value of the <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> object. The value is converted to a <FONT FACE="courier, couriernew, monospaced size">boolean</FONT> value, if necessary. If value is omitted or is 0, -0, null, false, <FONT FACE="courier, couriernew, monospaced size">NaN</FONT>, undefined, or the empty string (<FONT FACE="courier, couriernew, monospaced size">""</FONT>), the object has an initial value of false. All other values, including any object or the string <FONT FACE="courier, couriernew, monospaced size">"false"</FONT>, create an object with an initial value of true.</ztabletext></FONT>&nbsp;</TD>  </TR></TABLE><P></zparagraph></FONT><P><BR><A NAME="1193162"> </A><A NAME="Description"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Description</zrefheader></B></FONT><BR><A NAME="1196612"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Do not confuse the primitive Boolean values true and false with the true and false values of the Boolean object.</zparagraph></FONT><P><A NAME="1197972"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Any object whose value is not <FONT FACE="courier, couriernew, monospaced size">undefined</FONT> or <FONT FACE="courier, couriernew, monospaced size">null</FONT>, including a Boolean object whose value is false, evaluates to true when passed to a conditional statement. For example, the condition in the following <FONT FACE="courier, couriernew, monospaced size">if</FONT> statement evaluates to <FONT FACE="courier, couriernew, monospaced size">true</FONT>:</zparagraph></FONT><P><A NAME="1196613"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>x = new Boolean(false);<br>if(x) //the condition is true</zcodeline></FONT><P><A NAME="1196614"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>This behavior does not apply to Boolean primitives. For example, the condition in the following <FONT FACE="courier, couriernew, monospaced size">if</FONT> statement evaluates to <FONT FACE="courier, couriernew, monospaced size">false</FONT>:</zparagraph></FONT><P><A NAME="1196615"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>x = false;<br>if(x) //the condition is false</zcodeline></FONT><P><A NAME="1193163"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Do not use a <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> object to convert a non-boolean value to a boolean value. Instead, use Boolean as a function to perform this task:</zparagraph></FONT><P><A NAME="1196744"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>x = Boolean(expression) //preferred<br>x = new Boolean(expression) //don't use</zcodeline></FONT><P><A NAME="1196721"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>If you specify any object, including a Boolean object whose value is false, as the initial value of a Boolean object, the new Boolean object has a value of true.</zparagraph></FONT><P><A NAME="1196240"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline>myFalse=new Boolean(false) &nbsp;&nbsp;// initial value of false<br>g=new Boolean(myFalse) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//initial value of true<br>myString=new String("Hello") // string object<br>s=new Boolean(myString) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//initial value of true</zcodeline></FONT><P><A NAME="1196210"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>Do not use a Boolean object in place of a Boolean primitive.</zparagraph></FONT><P><BR><A NAME="1193171"> </A><A NAME="Backward Compatibility"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Backward Compatibility</zrefheader></B></FONT><BR><P><A NAME="1193172"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zheadrunin>JavaScript 1.2 and earlier versions. </zheadrunin></B></FONT><A NAME="1193173"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph>The <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> object behaves as follows:</zparagraph></FONT><P><ul><A NAME="1198083"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B>  <li></B><zsmartlist1>When a <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> object is used as the condition in a conditional test, JavaScript returns the value of the <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> object. For example, a <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> object whose value is false is treated as the primitive value false, and a <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> object whose value is true is treated as the primitive value <FONT FACE="courier, couriernew, monospaced size">true</FONT> in conditional tests. If the <FONT FACE="courier, couriernew, monospaced size">Boolean</FONT> object is a <FONT FACE="courier, couriernew, monospaced size">false</FONT> object, the conditional statement evaluates to <FONT FACE="courier, couriernew, monospaced size">false</FONT>.</zsmartlist1></FONT><P><A NAME="1197973"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B>  <li></B><zsmartlist1>You can use a Boolean object in place of a Boolean primitive.</zsmartlist1></FONT><P></ul><BR><A NAME="1193174"> </A><A NAME="Property Summary"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Property Summary</zrefheader></B></FONT><BR><A NAME="1193187"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><zparagraph><BR><P><TABLE WIDTH="90%" BORDER="1" CELLPADDING="5" CELLSPACING="0">  <CAPTION></CAPTION><P><FONT FACE=""><B></B></FONT><BR><BR>  <TR BGCOLOR="#CCCCCC" ALIGN=LEFT VALIGN=TOP>    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1193177"> </A><P ALIGN="LEFT"><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><ztablehead>Property</ztablehead></B></FONT></TH>    <TH VALIGN=TOP ALIGN=LEFT><A NAME="1193179"> </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><A NAME="1195491"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline><A HREF="boolean.html#1195419"  >constructor</A></zcodeline></FONT><P>&nbsp;</TD>    <TD VALIGN=TOP><P><A NAME="1195493"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>Specifies the function that creates an object's prototype.</ztabletext></FONT>&nbsp;</TD>  </TR>  <TR>    <TD VALIGN=TOP><A NAME="1193184"></A><FONT FACE="courier, couriernew, monospaced size" SIZE="2"><zcodeline><A HREF="boolean.html#1193217"  >prototype</A></zcodeline></FONT><P>&nbsp;</TD>    <TD VALIGN=TOP><P><A NAME="1193186"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><ztabletext>Defines a property that is shared by all Boolean objects.</ztabletext></FONT>&nbsp;</TD>  </TR></TABLE><P></zparagraph></FONT><P><BR><A NAME="1193188"> </A><A NAME="Method Summary"> </A><FONT FACE="Arial, Helvetica, sans-serif" SIZE="2"><B><zrefheader>Method Summary</zrefheader></B>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -