diff options
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/object')
10 files changed, 56 insertions, 56 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html index 1e1080be00..080c859773 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/assign/index.html @@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign <h2 id="Syntax" name="Syntax">语法</h2> -<pre class="syntaxbox notranslate"><code>Object.assign(<var>target</var>, ...<var>sources</var>)</code></pre> +<pre class="syntaxbox"><code>Object.assign(<var>target</var>, ...<var>sources</var>)</code></pre> <h3 id="Parameters" name="Parameters">参数</h3> @@ -53,7 +53,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign <p>这个 <a href="/zh-CN/docs/Glossary/Polyfill">polyfill</a> 不支持 symbol 属性, 由于 ES5 中本来就不存在 symbols :</p> -<pre class="notranslate">if (typeof Object.assign !== 'function') { +<pre>if (typeof Object.assign !== 'function') { // Must be writable: true, enumerable: false, configurable: true Object.defineProperty(Object, "assign", { value: function assign(target, varArgs) { // .length of function is 2 @@ -87,7 +87,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/assign <h3 id="Example_Cloning_an_object" name="Example:_Cloning_an_object">复制一个对象</h3> -<pre class="brush: js notranslate">const obj = { a: 1 }; +<pre class="brush: js">const obj = { a: 1 }; const copy = Object.assign({}, obj); console.log(copy); // { a: 1 } </pre> @@ -98,7 +98,7 @@ console.log(copy); // { a: 1 } <p>假如源值是一个对象的引用,它仅仅会复制其引用值。</p> -<pre class="brush: js notranslate">const log = console.log; +<pre class="brush: js">const log = console.log; function test() { 'use strict'; @@ -139,7 +139,7 @@ test(); <h3 id="Example_Merging_objects" name="Example:_Merging_objects">合并对象</h3> -<pre class="brush: js notranslate">const o1 = { a: 1 }; +<pre class="brush: js">const o1 = { a: 1 }; const o2 = { b: 2 }; const o3 = { c: 3 }; @@ -150,7 +150,7 @@ console.log(o1); // { a: 1, b: 2, c: 3 }, 注意目标对象自身也会改变 <h3 id="合并具有相同属性的对象">合并具有相同属性的对象</h3> -<pre class="brush: js notranslate">const o1 = { a: 1, b: 1, c: 1 }; +<pre class="brush: js">const o1 = { a: 1, b: 1, c: 1 }; const o2 = { b: 2, c: 2 }; const o3 = { c: 3 }; @@ -161,7 +161,7 @@ console.log(obj); // { a: 1, b: 2, c: 3 }</pre> <h3 id="Example_Symbol_properties" name="Example:_Symbol_properties">拷贝 symbol 类型的属性</h3> -<pre class="brush: js notranslate">const o1 = { a: 1 }; +<pre class="brush: js">const o1 = { a: 1 }; const o2 = { [Symbol('foo')]: 2 }; const obj = Object.assign({}, o1, o2); @@ -170,7 +170,7 @@ Object.getOwnPropertySymbols(obj); // [Symbol(foo)]</pre> <h3 id="Example_Only_own_enumerable_properties" name="Example:_Only_own_enumerable_properties">继承属性和不可枚举属性是不能拷贝的</h3> -<pre class="brush: js notranslate">const obj = Object.create({foo: 1}, { // foo 是个继承属性。 +<pre class="brush: js">const obj = Object.create({foo: 1}, { // foo 是个继承属性。 bar: { value: 2 // bar 是个不可枚举属性。 }, @@ -186,7 +186,7 @@ console.log(copy); // { baz: 3 } <h3 id="Example_Primitives" name="Example:_Primitives">原始类型会被包装为对象</h3> -<pre class="brush: js notranslate">const v1 = "abc"; +<pre class="brush: js">const v1 = "abc"; const v2 = true; const v3 = 10; const v4 = Symbol("foo") @@ -198,7 +198,7 @@ console.log(obj); // { "0": "a", "1": "b", "2": "c" }</pre> <h3 id="Example_Exceptions" name="Example:_Exceptions">异常会打断后续拷贝任务</h3> -<pre class="brush: js notranslate">const target = Object.defineProperty({}, "foo", { +<pre class="brush: js">const target = Object.defineProperty({}, "foo", { value: 1, writable: false }); // target 的 foo 属性是个只读属性。 @@ -216,7 +216,7 @@ console.log(target.baz); // undefined,第三个源对象更是不会被拷贝 <h3 id="Example_Copy_accessors" name="Example:_Copy_accessors">拷贝访问器</h3> -<pre class="brush: js notranslate">const obj = { +<pre class="brush: js">const obj = { foo: 1, get bar() { return 2; @@ -255,7 +255,7 @@ console.log(copy); <p>此{{Glossary("Polyfill","polyfill")}}不支持 symbol 属性,因为ES5 中根本没有 symbol :</p> -<pre class="brush: js notranslate">if (typeof Object.assign != 'function') { +<pre class="brush: js">if (typeof Object.assign != 'function') { // Must be writable: true, enumerable: false, configurable: true Object.defineProperty(Object, "assign", { value: function assign(target, varArgs) { // .length of function is 2 diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html index 073605d77f..671c542a48 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/create/index.html @@ -20,7 +20,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/create <h2 id="Syntax" name="Syntax">语法</h2> -<pre class="notranslate">Object.create(<var>proto,[</var><var>propertiesObject</var>])</pre> +<pre>Object.create(<var>proto,[</var><var>propertiesObject</var>])</pre> <h3 id="Parameters" name="Parameters">参数</h3> @@ -45,7 +45,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/create <p>下面的例子演示了如何使用<code>Object.create()</code>来实现类式继承。这是一个所有版本JavaScript都支持的单继承。</p> -<pre class="brush: js notranslate">// Shape - 父类(superclass) +<pre class="brush: js">// Shape - 父类(superclass) function Shape() { this.x = 0; this.y = 0; @@ -77,7 +77,7 @@ rect.move(1, 1); // Outputs, 'Shape moved.'</pre> <p>如果你希望能继承到多个对象,则可以使用混入的方式。</p> -<pre class="brush: js notranslate">function MyClass() { +<pre class="brush: js">function MyClass() { SuperClass.call(this); OtherSuperClass.call(this); } @@ -98,7 +98,7 @@ MyClass.prototype.myMethod = function() { <h3 id="使用_Object.create_的_propertyObject参数">使用 <code>Object.create</code> 的 <code>propertyObject</code>参数</h3> -<pre class="brush: js notranslate">var o; +<pre class="brush: js">var o; // 创建一个原型为null的空对象 o = Object.create(null); @@ -167,7 +167,7 @@ o2 = Object.create({}, { <p>请注意,尽管在 ES5 中 <code>Object.create</code>支持设置为<code>[[Prototype]]</code>为<code>null</code>,但因为那些ECMAScript5以前版本限制,此 polyfill 无法支持该特性。</p> -<pre class="brush: js notranslate">if (typeof Object.create !== "function") { +<pre class="brush: js">if (typeof Object.create !== "function") { Object.create = function (proto, propertiesObject) { if (typeof proto !== 'object' && typeof proto !== 'function') { throw new TypeError('Object prototype may only be an Object: ' + proto); diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperties/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperties/index.html index 483bcdf234..e4d9e9ef7a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperties/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperties/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperties <h2 id="Syntax" name="Syntax">语法</h2> -<pre class="notranslate"><code>Object.defineProperties(<var>obj</var>, <var>props</var>)</code></pre> +<pre><code>Object.defineProperties(<var>obj</var>, <var>props</var>)</code></pre> <h3 id="Parameters" name="Parameters">参数</h3> @@ -63,7 +63,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperties <h2 id="例子">例子</h2> -<pre class="brush: js notranslate">var obj = {}; +<pre class="brush: js">var obj = {}; Object.defineProperties(obj, { 'property1': { value: true, @@ -80,7 +80,7 @@ Object.defineProperties(obj, { <p>假设一个原始的执行环境,所有的名称和属性都引用它们的初始值,<code>Object.defineProperties</code>几乎完全等同于(注意<code>isCallable</code>中的注释)以下JavaScript中的重新实现:</p> -<pre class="brush: js notranslate">function defineProperties(obj, properties) { +<pre class="brush: js">function defineProperties(obj, properties) { function convertToDescriptor(desc) { function hasProperty(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html index c711f8b4d5..b37662d5ab 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/defineproperty/index.html @@ -25,7 +25,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperty <h2 id="语法">语法</h2> -<pre class="syntaxbox notranslate">Object.defineProperty(<var>obj</var>, <var>prop</var>, <var>descriptor</var>)</pre> +<pre class="syntaxbox">Object.defineProperty(<var>obj</var>, <var>prop</var>, <var>descriptor</var>)</pre> <h3 id="参数">参数</h3> @@ -135,7 +135,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/defineProperty <p>记住,这些选项不一定是自身属性,也要考虑继承来的属性。为了确认保留这些默认值,在设置之前,可能要冻结 {{jsxref("Object.prototype")}},明确指定所有的选项,或者通过 {{jsxref("Object.create", "Object.create(null)")}} 将 {{jsxref("Object.prototype.__proto__", "__proto__")}} 属性指向 {{jsxref("null")}}。</p> -<pre class="brush: js notranslate">// 使用 __proto__ +<pre class="brush: js">// 使用 __proto__ var obj = {}; var descriptor = Object.create(null); // 没有继承的属性 // 默认没有 enumerable,没有 configurable,没有 writable @@ -178,7 +178,7 @@ Object.defineProperty(obj, "key", withValue("static")); <p>如果对象中不存在指定的属性,<code>Object.defineProperty()</code> 会创建这个属性。当描述符中省略某些字段时,这些字段将使用它们的默认值。</p> -<pre class="brush: js notranslate">var o = {}; // 创建一个新对象 +<pre class="brush: js">var o = {}; // 创建一个新对象 // 在对象中添加一个属性与数据描述符的示例 Object.defineProperty(o, "a", { @@ -225,7 +225,7 @@ Object.defineProperty(o, "conflict", { <p>当 <code>writable</code> 属性设置为 <code>false</code> 时,该属性被称为“不可写的”。它不能被重新赋值。</p> -<pre class="brush: js notranslate">var o = {}; // 创建一个新对象 +<pre class="brush: js">var o = {}; // 创建一个新对象 Object.defineProperty(o, 'a', { value: 37, @@ -256,7 +256,7 @@ console.log(o.a); // logs 37. The assignment didn't work. <p><code>enumerable</code> 定义了对象的属性是否可以在 {{jsxref("Statements/for...in", "for...in")}} 循环和 {{jsxref("Object.keys()")}} 中被枚举。</p> -<pre class="brush: js notranslate">var o = {}; +<pre class="brush: js">var o = {}; Object.defineProperty(o, "a", { value : 1, enumerable: true }); Object.defineProperty(o, "b", { value : 2, enumerable: false }); Object.defineProperty(o, "c", { value : 3 }); // enumerable 默认为 false @@ -296,7 +296,7 @@ p[Symbol.for('f')] // undefined</pre> <p><code>configurable</code> 特性表示对象的属性是否可以被删除,以及除 <code>value</code> 和 <code>writable</code> 特性外的其他特性是否可以被修改。</p> -<pre class="brush: js notranslate">var o = {}; +<pre class="brush: js">var o = {}; Object.defineProperty(o, 'a', { get() { return 1; }, configurable: false @@ -329,7 +329,7 @@ console.log(o.a); // logs 1</pre> <p>考虑特性被赋予的默认特性值非常重要,通常,使用点运算符和 <code>Object.defineProperty()</code> 为对象的属性赋值时,数据描述符中的属性默认值是不同的,如下例所示。</p> -<pre class="brush: js notranslate">var o = {}; +<pre class="brush: js">var o = {}; o.a = 1; // 等同于: @@ -356,7 +356,7 @@ Object.defineProperty(o, "a", { <p>下面的例子展示了如何实现一个自存档对象。当设置<code>temperature</code> 属性时,<code>archive</code> 数组会收到日志条目。</p> -<pre class="brush: js notranslate">function Archiver() { +<pre class="brush: js">function Archiver() { var temperature = null; var archive = []; @@ -382,7 +382,7 @@ arc.getArchive(); // [{ val: 11 }, { val: 13 }]</pre> <p>下面这个例子中,getter 总是会返回一个相同的值。</p> -<pre class="brush: js notranslate">var pattern = { +<pre class="brush: js">var pattern = { get: function () { return 'I alway return this string,whatever you have assigned'; }, @@ -409,7 +409,7 @@ console.log(instance.myname);</pre> <p>如果访问者的属性是被继承的,它的 <code>get</code> 和 <code>set</code> 方法会在子对象的属性被访问或者修改时被调用。如果这些方法用一个变量存值,该值会被所有对象共享。</p> -<pre class="brush: js notranslate">function myclass() { +<pre class="brush: js">function myclass() { } var value; @@ -430,7 +430,7 @@ console.log(b.x); // 1 <p>这可以通过将值存储在另一个属性中解决。在 <code>get</code> 和 <code>set</code> 方法中,<code>this</code> 指向某个被访问和修改属性的对象。</p> -<pre class="brush: js notranslate">function myclass() { +<pre class="brush: js">function myclass() { } Object.defineProperty(myclass.prototype, "x", { @@ -449,7 +449,7 @@ console.log(b.x); // undefined</pre> <p>不像访问者属性,值属性始终在对象自身上设置,而不是一个原型。然而,如果一个不可写的属性被继承,它仍然可以防止修改对象的属性。</p> -<pre class="brush: js notranslate">function myclass() { +<pre class="brush: js">function myclass() { } myclass.prototype.x = 1; diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/fromentries/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/fromentries/index.html index 80cb1de95a..d7b9c46865 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/fromentries/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/fromentries/index.html @@ -13,7 +13,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/fromEntries <h2 id="语法">语法</h2> -<pre class="syntaxbox notranslate">Object.fromEntries(<var>iterable</var>);</pre> +<pre class="syntaxbox">Object.fromEntries(<var>iterable</var>);</pre> <h3 id="参数">参数</h3> @@ -38,7 +38,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/fromEntries <p>通过 <code>Object.fromEntries</code>, 可以将 {{jsxref("Map")}} 转换为 {{jsxref("Object")}}:</p> -<pre class="brush: js notranslate">const map = new Map([ ['foo', 'bar'], ['baz', 42] ]); +<pre class="brush: js">const map = new Map([ ['foo', 'bar'], ['baz', 42] ]); const obj = Object.fromEntries(map); console.log(obj); // { foo: "bar", baz: 42 } </pre> @@ -47,7 +47,7 @@ console.log(obj); // { foo: "bar", baz: 42 } <p>通过 <code>Object.fromEntries</code>, 可以将 {{jsxref("Array")}} 转换为 {{jsxref("Object")}}:</p> -<pre class="brush: js notranslate">const arr = [ ['0', 'a'], ['1', 'b'], ['2', 'c'] ]; +<pre class="brush: js">const arr = [ ['0', 'a'], ['1', 'b'], ['2', 'c'] ]; const obj = Object.fromEntries(arr); console.log(obj); // { 0: "a", 1: "b", 2: "c" } </pre> @@ -56,7 +56,7 @@ console.log(obj); // { 0: "a", 1: "b", 2: "c" } <p><code>Object.fromEntries</code> 是与 {{jsxref("Object.entries()")}} 相反的方法,用 <a href="/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array#Methods_2">数组处理函数</a> 可以像下面这样转换对象:</p> -<pre class="brush: js notranslate">const object1 = { a: 1, b: 2, c: 3 }; +<pre class="brush: js">const object1 = { a: 1, b: 2, c: 3 }; const object2 = Object.fromEntries( Object.entries(object1) diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.html index a5b4088128..08874a06e8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/getownpropertydescriptor/index.html @@ -16,7 +16,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes <h2 id="Syntax" name="Syntax">语法</h2> -<pre class="syntaxbox notranslate">Object.getOwnPropertyDescriptor(<em>obj</em>, <em>prop</em>)</pre> +<pre class="syntaxbox">Object.getOwnPropertyDescriptor(<em>obj</em>, <em>prop</em>)</pre> <h3 id="Parameters" name="Parameters">参数</h3> @@ -54,7 +54,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDes <h2 id="Examples" name="Examples">示例</h2> -<pre class="brush: js notranslate">var o, d; +<pre class="brush: js">var o, d; o = { get foo() { return 17; } }; d = Object.getOwnPropertyDescriptor(o, "foo"); @@ -92,7 +92,7 @@ d = Object.getOwnPropertyDescriptor(o, "baz"); <p>在 ES5 中,如果该方法的第一个参数不是对象(而是原始类型),那么就会产生出现 {{jsxref("TypeError")}}。而在 ES2015,第一个的参数不是对象的话就会被强制转换为对象。</p> -<pre class="brush: js notranslate">Object.getOwnPropertyDescriptor('foo', 0); +<pre class="brush: js">Object.getOwnPropertyDescriptor('foo', 0); // 类型错误: "foo" 不是一个对象 // ES5 code Object.getOwnPropertyDescriptor('foo', 0); diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/hasownproperty/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/hasownproperty/index.html index 70f5f307d6..b0c254e52a 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/hasownproperty/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/hasownproperty/index.html @@ -22,7 +22,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty <h2 id="语法">语法</h2> -<pre class="syntaxbox notranslate"><var>obj</var>.hasOwnProperty(<var>prop</var>)</pre> +<pre class="syntaxbox"><var>obj</var>.hasOwnProperty(<var>prop</var>)</pre> <h3 id="参数">参数</h3> @@ -43,7 +43,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/hasOwnProperty <p>即使属性的值是 <code>null</code> 或 <code>undefined</code>,只要属性存在,<code>hasOwnProperty</code> 依旧会返回 <code>true</code>。</p> -<pre class="brush: js notranslate">o = new Object(); +<pre class="brush: js">o = new Object(); o.propOne = null; o.hasOwnProperty('propOne'); // 返回 true o.propTwo = undefined; @@ -56,7 +56,7 @@ o.hasOwnProperty('propTwo'); // 返回 true <p>下面的例子检测了对象 <code>o</code> 是否含有自身属性 <code>prop</code>:</p> -<pre class="brush: js notranslate">o = new Object(); +<pre class="brush: js">o = new Object(); o.hasOwnProperty('prop'); // 返回 false o.prop = 'exists'; o.hasOwnProperty('prop'); // 返回 true @@ -68,7 +68,7 @@ o.hasOwnProperty('prop'); // 返回 false <p>下面的例子演示了 <code>hasOwnProperty</code> 方法对待自身属性和继承属性的区别:</p> -<pre class="brush: js notranslate">o = new Object(); +<pre class="brush: js">o = new Object(); o.prop = 'exists'; o.hasOwnProperty('prop'); // 返回 true o.hasOwnProperty('toString'); // 返回 false @@ -79,7 +79,7 @@ o.hasOwnProperty('hasOwnProperty'); // 返回 false <p>下面的例子演示了如何在遍历一个对象的所有属性时忽略掉继承属性,注意这里 {{jsxref("Statements/for...in", "for...in")}} 循环只会遍历可枚举属性,所以不应该基于这个循环中没有不可枚举的属性而得出 <code>hasOwnProperty</code> 是严格限制于可枚举项目的(如同 {{jsxref("Object.getOwnPropertyNames()")}})。</p> -<pre class="brush: js notranslate">var buz = { +<pre class="brush: js">var buz = { fog: 'stack' }; @@ -98,7 +98,7 @@ for (var name in buz) { <p>JavaScript 并没有保护 <code>hasOwnProperty</code> 这个属性名,因此,当某个对象可能自有一个占用该属性名的属性时,就需要使用外部的 <code>hasOwnProperty</code> 获得正确的结果:</p> -<pre class="brush: js notranslate">var foo = { +<pre class="brush: js">var foo = { hasOwnProperty: function() { return false; }, diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/index.html index cd90b70b07..e143a7d49d 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/index.html @@ -139,24 +139,24 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object <p>下面的例子将一个空的 <code>Object</code> 对象存到 <code>o</code> 中:</p> -<pre class="brush: js notranslate">var o = new Object(); +<pre class="brush: js">var o = new Object(); </pre> -<pre class="brush: js notranslate">var o = new Object(undefined); +<pre class="brush: js">var o = new Object(undefined); </pre> -<pre class="brush: js notranslate">var o = new Object(null); +<pre class="brush: js">var o = new Object(null); </pre> <h3 id="使用_Object_生成布尔对象">使用 <code>Object</code> 生成布尔对象</h3> <p>下面的例子将{{jsxref("Boolean")}} 对象存到 <code>o</code> 中:</p> -<pre class="brush: js notranslate">// 等价于 o = new Boolean(true); +<pre class="brush: js">// 等价于 o = new Boolean(true); var o = new Object(true); </pre> -<pre class="brush: js notranslate">// 等价于 o = new Boolean(false); +<pre class="brush: js">// 等价于 o = new Boolean(false); var o = new Object(Boolean()); </pre> diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/is/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/is/index.html index 9c3aff1abd..04a528b7b8 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/is/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/is/index.html @@ -17,7 +17,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/is <p><strong>语法</strong></p> <p> - </p><pre class="syntaxbox notranslate"><code>Object.is(<var>value1</var>, <var>value2</var>);</code></pre> + </p><pre class="syntaxbox"><code>Object.is(<var>value1</var>, <var>value2</var>);</code></pre> <h3 id="参数">参数</h3> @@ -59,7 +59,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/is <h2 id="Polyfill">Polyfill</h2> -<pre class="brush: js notranslate">if (!Object.is) { +<pre class="brush: js">if (!Object.is) { Object.is = function(x, y) { // SameValue algorithm if (x === y) { // Steps 1-5, 7-10 @@ -99,7 +99,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/is <h3 id="使用_Object.is">使用 Object.is</h3> -<pre class="brush: js notranslate">Object.is('foo', 'foo'); // true +<pre class="brush: js">Object.is('foo', 'foo'); // true Object.is(window, window); // true Object.is('foo', 'bar'); // false diff --git a/files/zh-cn/web/javascript/reference/global_objects/object/issealed/index.html b/files/zh-cn/web/javascript/reference/global_objects/object/issealed/index.html index d4bb3a438e..e6a895f345 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/object/issealed/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/object/issealed/index.html @@ -14,7 +14,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isSealed <h2 id="语法">语法</h2> -<pre class="syntaxbox notranslate"><code>Object.isSealed(<em>obj</em>)</code></pre> +<pre class="syntaxbox"><code>Object.isSealed(<em>obj</em>)</code></pre> <h3 id="参数">参数</h3> @@ -33,7 +33,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Object/isSealed <h2 id="Examples" name="Examples">例子</h2> -<pre class="brush: js notranslate">// 新建的对象默认不是密封的. +<pre class="brush: js">// 新建的对象默认不是密封的. var empty = {}; Object.isSealed(empty); // === false @@ -72,7 +72,7 @@ Object.isFrozen(s3); // === true ,访问器属性不考虑可写不可写,只 <p>在ES5中,如果这个方法的参数不是一个对象(一个原始类型),那么它会导致{{jsxref("TypeError")}}。在ES2015中,非对象参数将被视为是一个密封的普通对象,只返回<code>true</code>。</p> -<pre class="brush: js notranslate">Object.isSealed(1); +<pre class="brush: js">Object.isSealed(1); // TypeError: 1 is not an object (ES5 code) Object.isSealed(1); |