<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Bo-Blog的另类集散地]]></title> 
<link>https://bb.y48.net/index.php</link> 
<description><![CDATA[自由的翱翔]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Bo-Blog的另类集散地]]></copyright>
<item>
<link>https://bb.y48.net/read.php?5</link>
<title><![CDATA[JavaScript的数据类型]]></title> 
<author>james &lt;admin@yourname.com&gt;</author>
<category><![CDATA[JavaScript]]></category>
<pubDate>Sun, 21 Apr 2019 08:22:49 +0000</pubDate> 
<guid>https://bb.y48.net/read.php?5</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><strong><span style="font-size: 14pt; font-family: &quot;Times New Roman&quot;; color: black">1</span><span style="font-size: 14pt; font-family: 宋体; color: black">．整型数据</span></strong></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span style="font-size: x-small; font-family: helvetica">在</span></span><span style="font-size: x-small; font-family: helvetica"><span style="font-size: 14pt; color: black">JavaScript</span><span style="font-size: 14pt; color: black">程序中，十进制的整数是一个数字序列。例如：</span></span></p><span style="font-size: x-small; font-family: helvetica">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small; font-family: helvetica"><span style="font-size: 14pt; color: black">0</span></span></p><span style="font-size: x-small; font-family: helvetica">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small; font-family: helvetica"><span style="font-size: 14pt; color: black">7</span></span></p><span style="font-size: x-small; font-family: helvetica">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small; font-family: helvetica"><span style="font-size: 14pt; color: black">﹣8</span></span></p><span style="font-size: x-small; font-family: helvetica">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small; font-family: helvetica"><span style="font-size: 14pt; color: black">1000</span></span></p><span style="font-size: x-small; font-family: helvetica">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small; font-family: helvetica"><span style="font-size: 14pt; color: black"><span>&nbsp; </span>JavaScript</span><span style="font-size: 14pt; color: black">的数字格式允许精确地表示</span><span style="font-size: 14pt; color: black">﹣900719925474092</span><span style="font-size: 14pt; color: black">（</span><span style="font-size: 14pt; color: black">﹣253</span><span style="font-size: 14pt; color: black">）和</span><span style="font-size: 14pt; color: black">900719925474092</span><span style="font-size: 14pt; color: black">（</span><span style="font-size: 14pt; color: black">253</span><span style="font-size: 14pt; color: black">）之间的所有整数（包括</span><span style="font-size: 14pt; color: black">﹣900719925474092</span><span style="font-size: 14pt; color: black">（</span><span style="font-size: 14pt; color: black">﹣253</span><span style="font-size: 14pt; color: black">）和</span><span style="font-size: 14pt; color: black">900719925474092</span><span style="font-size: 14pt; color: black">（</span><span style="font-size: 14pt; color: black">253</span><span style="font-size: 14pt; color: black">））。但是使用超过这个范围的整数，就会失去尾数的精确性。需要注意的是，</span><span style="font-size: 14pt; color: black">JavaScript</span><span style="font-size: 14pt; color: black">中的某些整数运算是对</span><span style="font-size: 14pt; color: black">32</span><span style="font-size: 14pt; color: black">位的整数执行的，它们的范围从</span><span style="font-size: 14pt; color: black">﹣2147483648</span><span style="font-size: 14pt; color: black">（</span><span style="font-size: 14pt; color: black">﹣231</span><span style="font-size: 14pt; color: black">）到</span><span style="font-size: 14pt; color: black">2147483647</span><span style="font-size: 14pt; color: black">（</span><span style="font-size: 14pt; color: black">231-1</span><span style="font-size: 14pt; color: black">）。</span></span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: bold; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>2</span><span style="font-size: 14pt; font-weight: bold; font-family: 宋体; color: black">．十六进制和八进制</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp;<span style="font-size: x-small"> </span></span><span style="font-size: x-small">JavaScript</span></span><span style="font-size: x-small"><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">不但能够处理十进制的整型数据，还能识别十六进制（以</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">16</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">为基数）的数据。所谓十六进制数据，是以&ldquo;</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0X</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&rdquo;</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">和&ldquo;</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0x</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&rdquo;</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">开头，其后跟随十六进制数字串的直接量。十六进制的数字可以是</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">到</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">9</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">中的某个数字，也可以是</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">a</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">（</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">A</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">）到</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">f</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">（</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">F</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">）中的某个字母，它们用来表示</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">到</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">15</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">之间（包括</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">和</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">15</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">）的某个值，下面是十六进制整型数据的例子：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0xff</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>//15*16+15=225</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">（基数为</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">10</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">）</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0xCAFE911</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>尽管</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">ECMAScripr</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">标准不支持八进制数据，但是</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">的某些实现却允许采用八进制（基数为</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">8</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">）格式的整型数据。八进制数据以数字</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">开头，其后跟随一个数字序列，这个序列中的每个数字都在</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">和</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">7</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">之间（包括</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">和</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">7</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">），例如：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0377<span>&nbsp; </span>//3*64+7*8+7=255</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">（基数为</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">10</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">）</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>由于某些</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">实现支持八进制数据，而有些则不支持，所以最好不要使用以</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">开头的整型数据，因为不知道某个</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">的实现是将其解释为十进制，还是解释为八进制。</span></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><br /><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">&nbsp;&nbsp;</span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 18pt; font-weight: bold; font-family: &quot;Times New Roman&quot;; color: black">3</span><span style="font-size: 18pt; font-weight: bold; font-family: 宋体; color: black">．浮点型数据</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span style="font-size: x-small">浮点型数据可以具有小数点，它们采用的是传统科学记数法的语法。一个实数值可以被表示为整数部分后加小数点和小数部分。</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>此外，还可以使用指数法表示浮点型数据，即实数后跟随字母</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">e</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">或</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">E</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">，后面加上正负号，其后再加一个整型指数。这种记数法表示的数值等于前面的实数乘以</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">10</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">的指数次幂。</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>语法：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp;</span></span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">[digits] [.digits] [(</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">E&#124;e</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">[(+&#124;-)])]</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>例如：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">1.2</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">.33333333</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: left; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">3.12e11</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>//3.12&times;1011</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;<span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">1.234E﹣12</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>//1.234&times;10﹣12</span></span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><strong><span style="font-size: 14pt; font-family: 宋体; color: black"><br /></span></strong></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: medium"><strong><span style="font-size: 14pt; font-family: 宋体; color: black">4.字符串</span></strong></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><br /><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">&nbsp;&nbsp;</span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>字符串（</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">string</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">）是由</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">Unicode</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">字符、数字、标点符号等组成的序列，它是</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">用来表示文本的数据类型。程序中的字符串型数据是包含在单引号或双引号中的，由单引号定界的字符串中可以含有双引号，由双引号定界的字符串中也可以含有单引号。</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>例如：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>（</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">1</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">）单引号括起来的一个或多个字符，代码如下：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">'</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">啊</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">'</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">'</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">活着的人却拥有着一颗沉睡的心</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">'</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>（</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">2</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">）双引号括起来的一个或多个字符，代码如下：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&quot;</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">呀</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&quot;</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&quot;</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">我想学习</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript&quot;</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>（</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">3</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">）单引号定界的字符串中可以含有双引号，代码如下：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">'name=&quot;</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">myname</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&quot;'</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>（</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">4</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">）双引号定界的字符串中可以含有单引号，代码如下：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&quot;You can call me 'Tom'!&quot;</span></span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black"><span style="font-size: medium"><strong>5.布尔类型</strong></span><br /></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><br /><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">&nbsp;&nbsp;</span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">数值数据类型和字符串数据类型的值都无穷多，但是布尔数据类型只有两个值，这两个合法的值分别由直接量&ldquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">true&rdquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">和&ldquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">false&rdquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">表示，它说明了某个事物是真还是假。</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>布尔值通常在</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">程序中用来比较所得的结果。例如：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">n==1</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>这行代码测试了变量</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">n</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">的值是否和数值</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">1</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">相等。如果相等，比较的结果就是布尔值</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">true</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">，否则结果就是</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">false</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">。</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>布尔值通常用于</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">的控制结构。例如，</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">的</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">if/else</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">语句就是在布尔值为</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">true</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">时执行一个动作，而在布尔值为</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">false</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">时执行另一个动作。通常将一个创建布尔值与使用这个比较的语句结合在一起。例如：</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">if (n==1)</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>m=</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">n+1</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">;</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">else</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">n=</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">n+1</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">;</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>本段代码检测了</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">n</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">是否等于</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">1</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">。如果相等，就给</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">m</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">增加</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">1</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">，否则给</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">n</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">加</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">1</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">。</span></span></p><span style="font-size: x-small">&nbsp;&nbsp;</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: x-small"><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>有时候可以把两个可能的布尔值看作是&ldquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">on</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">（</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">true</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">）&rdquo;和&ldquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">off</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">（</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">false</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">）&rdquo;，或者看作是&ldquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">yes</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">（</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">true</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">）&rdquo;和&ldquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">no</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">（</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">false</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">）&rdquo;，这样比将它们看作是&ldquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">true&rdquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">和&ldquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">false&rdquo;</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">更为直观。有时候把它们看作是</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">1</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">（</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">true</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">）和</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">（</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">false</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">）会更加有用（实际上</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">确实是这样做的，在必要时会将</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">true</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">转换成</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">1</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">，将</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">false</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">转换成</span><span style="font-size: 16pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 16pt; font-weight: normal; font-family: 宋体; color: black">）。</span></span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black"><br /></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black"><span style="font-size: x-small"><strong>6.特殊数据类型</strong></span><br /></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><br /><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">&nbsp;&nbsp;</span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: bold; font-family: &quot;Times New Roman&quot;; color: black">1</span><span style="font-size: 14pt; font-weight: bold; font-family: 宋体; color: black">．转义字符</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>以反斜杠开头的不可显示的特殊字符通常称为控制字符，也被称为转义字符。通过转义字符可以在字符串中添加不可显示的特殊字符，或者防止引号匹配混乱的问题。</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">常用的转义字符如表所示。</span><span style="font-size: 14pt; font-weight: bold; font-family: &quot;Lucida Sans Unicode&quot;; color: #669900"> </span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><br /><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">&nbsp;&nbsp;</span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">在</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">document.writeln</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">();</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">语句中使用转义字符时，只有将其放在格式化文本块中才会起作用，所以脚本必须在</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&lt;pre&gt;</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">和</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&lt;/pre&gt;</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">的标签内。</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>例如，下面是应用转义字符使字符串换行，程序代码如下：</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">document.writeln</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">(&quot;&lt;pre&gt;&quot;);</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">document.writeln</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">(&quot;</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">轻松学习</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&#92;</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">nJavaScript</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">语言！</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&quot;);</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">document.writeln</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">(&quot;&lt;/pre&gt;&quot;);</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>运行结果：</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">轻松学习</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">语言！</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>如果上述代码不使用</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&lt;pre&gt;</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">和</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&lt;/pre&gt;</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">的标签，则转义字符不起作用，代码如下：</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">document.writeln</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">(&quot;</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">快快乐乐</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&#92;n</span><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">平平安安！</span><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&quot;);</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>运行结果：</span></p>&nbsp;&nbsp;<span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">快快乐乐平平安安！</span><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><br /><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black">&nbsp;&nbsp;</span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 18pt; font-weight: bold; font-family: &quot;Times New Roman&quot;; color: black">2</span><span style="font-size: 18pt; font-weight: bold; font-family: 宋体; color: black">．未定义值</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>未定义类型的变量是</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">undefined</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">，表示变量还没有赋值（如</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">var a;</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">），或者赋予一个不存在的属性值（如</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">var a=</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">String.notProperty</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">;</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">）。</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>此外，</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">中有一种特殊类型的数字常量</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">NaN</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">，即&ldquo;非数字&rdquo;。当在程序中由于某种原因发生计算错误后，将产生一个没有意义的数字，此时</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">JavaScript</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">返回的数字值就是</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">NaN</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">。</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span></span><span style="font-size: 18pt; font-weight: bold; font-family: &quot;Times New Roman&quot;; color: black">3</span><span style="font-size: 18pt; font-weight: bold; font-family: 宋体; color: black">．空值（</span><span style="font-size: 18pt; font-weight: bold; font-family: &quot;Times New Roman&quot;; color: black">null</span><span style="font-size: 18pt; font-weight: bold; font-family: 宋体; color: black">）</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>JavaScript</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">中的关键字</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">null</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">是一个特殊的值，它表示为空值，用于定义空的或不存在的引用。如果试图引用一个没有定义的变量，则返回一个</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">null</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">值。这里必须要注意的是：</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">null</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">不等同于空的字符串（</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">&quot;&quot;</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">）或</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">0</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">。</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black"><span>&nbsp; </span>由此可见，</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">null</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">与</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">undefined</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">的区别是，</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">null</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">表示一个变量被赋予了一个空值，而</span><span style="font-size: 18pt; font-weight: normal; font-family: &quot;Times New Roman&quot;; color: black">undefined</span><span style="font-size: 18pt; font-weight: normal; font-family: 宋体; color: black">则表示该变量尚未被赋值。</span></p>&nbsp;&nbsp;<p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black"><br /></span></p><p style="margin-top: 0pt; margin-bottom: 0pt; text-align: justify; direction: ltr; unicode-bidi: embed; vertical-align: baseline"><span style="font-size: 14pt; font-weight: normal; font-family: 宋体; color: black"><br /></span></p>&nbsp;&nbsp;<br/>Tags - <a href="https://bb.y48.net/tag.php?tag=javascript" rel="tag">javascript</a> , <a href="https://bb.y48.net/tag.php?tag=%25E6%2595%25B0%25E6%258D%25AE%25E7%25B1%25BB%25E5%259E%258B" rel="tag">数据类型</a>
]]>
</description>
</item>
</channel>
</rss>