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

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

@@ -5,7 +5,7 @@
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/object-prototype-seal.html" width="100%"></iframe></div>
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
<h2 id="Syntax" name="Syntax">语法</h2>
<pre class="syntaxbox"><code>Object.seal(<em>obj</em>)</code></pre>
<pre><code class="language-javascript"><code>Object.seal(<em>obj</em>)</code></code></pre>
<h3 id="Parameters" name="Parameters">参数</h3>
<dl>
<dt><code>obj</code></dt>
@@ -18,7 +18,7 @@
<p>不会影响从原型链上继承的属性。但 <a href="Reference/Global_Objects/Object/proto" title="使用__proto__是有争议的也不鼓励使用它。因为它从来没有被包括在EcmaScript语言规范中但是现代浏览器都实现了它。__proto__属性已在ECMAScript 6语言规范中标准化用于确保Web浏览器的兼容性因此它未来将被支持。它已被不推荐使用, 现在更推荐使用Object.getPrototypeOf/Reflect.getPrototypeOf 和Object.setPrototypeOf/Reflect.setPrototypeOf尽管如此设置对象的[[Prototype]]是一个缓慢的操作,如果性能是一个问题,应该避免)。"><code>__proto__</code></a> ( <span title="This deprecated API should no longer be used, but will probably still work."><i class="icon-thumbs-down-alt"> </i></span> ) 属性的值也会不能修改。</p>
<p>返回被密封对象的引用。</p>
<h2 id="Examples" name="Examples">例子</h2>
<pre class="brush: js">var obj = {
<pre><code class="language-javascript">var obj = {
prop: function() {},
foo: 'bar'
};
@@ -67,14 +67,14 @@ Object.defineProperty(obj, 'ohai', {
}); // throws a TypeError
Object.defineProperty(obj, 'foo', {
value: 'eit'
}); // changes existing property value</pre>
}); // changes existing property value</code></pre>
<h2 id="注意">注意</h2>
<p>在ES5中如果这个方法的参数不是一个原始对象那么它将导致<a href="Reference/Global_Objects/TypeError" title="TypeError类型错误 对象用来表示值的类型非预期类型时发生的错误。"><code>TypeError</code></a>。在ES2015中非对象参数将被视为已被密封的普通对象会直接返回它。</p>
<pre class="brush: js">Object.seal(1);
<pre><code class="language-javascript">Object.seal(1);
// TypeError: 1 is not an object (ES5 code)
Object.seal(1);
// 1 (ES2015 code)</pre>
// 1 (ES2015 code)</code></pre>
<h3 id="对比_Object.freeze()">对比 <code>Object.freeze()</code></h3>
<p>使用<code>Object.freeze()</code>冻结的对象中的现有属性是不可变的。用<code>Object.seal()</code>密封的对象可以改变其现有属性。</p>
<h2 id="规范" style="margin-bottom: 20px; line-height: 30px;">规范</h2>