2019-04-21 11:50:48 +08:00

23 lines
1.5 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<article id="wikiArticle">
<div></div>
<h2 id="错误信息">错误信息</h2>
<pre><code class="language-javascript">TypeError: null has no properties
TypeError: undefined has no properties
</code></pre>
<h2 id="错误类型">错误类型</h2>
<p><a href="Reference/Global_Objects/TypeError" title="TypeError类型错误 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a>.</p>
<h2 id="哪里出错了">哪里出错了?</h2>
<p> <a href="Reference/Global_Objects/null" title="值 null 特指对象的值未设置。它是 JavaScript 基本类型 之一。"><code>null</code></a><a href="Reference/Global_Objects/undefined" title="undefined是全局对象的一个属性。也就是说它是全局作用域的一个变量。undefined的最初值就是原始数据类型undefined。"><code>undefined</code></a>中,没有你需要的属性。</p>
<h2 id="例子">例子</h2>
<pre><code class="language-js example-bad">null.foo;
// 错误类型: null没有这个属性
undefined.bar;
// 错误类型: undefined没有这个属性
</code></pre>
<h2 id="参考">参考</h2>
<ul>
<li><a href="Reference/Global_Objects/null" title="值 null 特指对象的值未设置。它是 JavaScript 基本类型 之一。"><code>null</code></a></li>
<li><a href="Reference/Global_Objects/undefined" title="undefined是全局对象的一个属性。也就是说它是全局作用域的一个变量。undefined的最初值就是原始数据类型undefined。"><code>undefined</code></a></li>
</ul>
</article>