aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html')
-rw-r--r--files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html10
1 files changed, 5 insertions, 5 deletions
diff --git a/files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html b/files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html
index b54e69bb3c..311c16ca50 100644
--- a/files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html
+++ b/files/zh-cn/web/javascript/reference/global_objects/reflect/construct/index.html
@@ -9,7 +9,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Reflect/construct
<h2 id="语法">语法</h2>
-<pre class="syntaxbox notranslate">Reflect.construct(target, argumentsList[, newTarget])
+<pre class="syntaxbox">Reflect.construct(target, argumentsList[, newTarget])
</pre>
<h3 id="参数">参数</h3>
@@ -35,14 +35,14 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Reflect/construct
<p><code>Reflect.construct</code>允许你使用可变的参数来调用构造函数 ,这和使用<a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/new">new操作符</a>搭配<a href="https://developer.mozilla.org/ zh-CN/docs/Web/JavaScript/Reference/Operators/new">对象展开符</a>调用一样。</p>
-<pre class="brush: js notranslate">var obj = new Foo(...args);
+<pre class="brush: js">var obj = new Foo(...args);
var obj = Reflect.construct(Foo, args); </pre>
<h3 id="Reflect.construct_vs_Object.create"><code>Reflect.construct()</code> vs <code>Object.create()</code></h3>
<p><code>在新语法Reflect</code>出现之前,是通过明确指定构造函数和原型对象( 使用{{jsxref("Object.create()")}})来创建一个对象的。</p>
-<pre class="brush: js notranslate">function OneClass() {
+<pre class="brush: js">function OneClass() {
this.name = 'one';
}
@@ -72,7 +72,7 @@ console.log(obj2 instanceof OtherClass); // true</pre>
<p>当调用<code>Reflect.construct()</code>来创建对象,<code>new.target</code>值会自动指定到<code>target</code>(或者newTarget,前提是newTarget指定了)。</p>
-<pre class="brush: js notranslate">function OneClass() {
+<pre class="brush: js">function OneClass() {
console.log('OneClass');
console.log(new.target);
}
@@ -101,7 +101,7 @@ OneClass.apply(obj3, args);
<h3 id="使用_Reflect.construct">使用 <code>Reflect.construct()</code></h3>
-<pre class="brush: js notranslate">var d = Reflect.construct(Date, [1776, 6, 4]);
+<pre class="brush: js">var d = Reflect.construct(Date, [1776, 6, 4]);
d instanceof Date; // true
d.getFullYear(); // 1776
</pre>