语法高亮,滚动条美化,设置页面调整

This commit is contained in:
fofolee
2019-04-19 02:41:09 +08:00
parent 1e8f76c000
commit 359d29ee0b
1590 changed files with 12328 additions and 11441 deletions

View File

@@ -1,12 +1,12 @@
<article id="wikiArticle">
<div></div>
<h2 id="报错消息">报错消息</h2>
<pre class="syntaxbox">TypeError: "x" is read-only (Firefox) //格式错误:"x"只读。(x可以代表任意值)
<pre><code class="language-javascript">TypeError: "x" is read-only (Firefox) //格式错误:"x"只读。(x可以代表任意值)
TypeError: 0 is read-only (Firefox)
TypeError: Cannot assign to read only property 'x' of #&lt;Object&gt; (Chrome)
//格式错误:对象的x属性是只读的不能设置 chrome
TypeError: Cannot assign to read only property '0' of [object Array] (Chrome)
</pre>
</code></pre>
<h2 id="错误格式">错误格式</h2>
<p><a href="Reference/Global_Objects/TypeError" title="TypeError类型错误 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a></p>
<h2 id="哪里出错了">哪里出错了?</h2>
@@ -15,7 +15,7 @@ TypeError: Cannot assign to read only property '0' of [object Array] (Chrome)
<h2 id="例如">例如</h2>
<h3 id="无效例子(也就是下面这么做会导致报这种错)">无效例子(也就是下面这么做会导致报这种错)</h3>
<p>只读属性不能直接创建, 但我们可以通过<a href="Reference/Global_Objects/Object/defineProperty" title="Object.defineProperty() 方法会直接在一个对象上定义一个新属性,或者修改一个对象的现有属性, 并返回这个对象。"><code>Object.defineProperty()</code></a><a href="Reference/Global_Objects/Object/freeze" title="Object.freeze() 方法可以冻结一个对象,冻结指的是不能向这个对象添加新的属性,不能修改其已有属性的值,不能删除已有属性,以及不能修改该对象已有属性的可枚举性、可配置性、可写性。该方法返回被冻结的对象。"><code>Object.freeze()</code></a>设置.</p>
<pre class="brush: js example-bad">"use strict";
<pre><code class="language-js example-bad">"use strict";
var obj = Object.freeze({name: "Elsa", score: 157});
obj.score = 0; // TypeError
@@ -30,21 +30,21 @@ frozenArray[0]++; // TypeError
还有几个JavaScript内置属性. 如果你尝试修改一个常量.
"use strict";
Math.PI = 4; // TypeError</pre>
Math.PI = 4; // TypeError</code></pre>
<p>傻了吧,报错了</p>
<p><code>全局变量undefined也是只读的</code>, 所以你不能忽视臭名昭著的"undefined is not a function"错误:</p>
<pre class="brush: js example-bad">"use strict";
<pre><code class="language-js example-bad">"use strict";
undefined = function () {}; // TypeError: "undefined" is read-only
</pre>
</code></pre>
<h3 id="下面这样都是有效,不报错的">下面这样都是有效,不报错的</h3>
<pre class="brush: js example-good">"use strict";
<pre><code class="language-js example-good">"use strict";
var obj = Object.freeze({name: "Score", points: 157});
obj = {name: obj.name, points: 0}; // 用一个新对象替换原来的对象(其实就是更改了对象的指针)
"use strict";
var LUNG_COUNT = 2; //
LUNG_COUNT = 3; //
</pre>
</code></pre>
<h2 id="参见">参见</h2>
<ul>
<li><a href="Reference/Global_Objects/Object/defineProperty" title="Object.defineProperty() 方法会直接在一个对象上定义一个新属性,或者修改一个对象的现有属性, 并返回这个对象。"><code>Object.defineProperty()</code></a></li>