From ee7a4fa42a1fcd60ff2225aaa0e797a2e3e0f5db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=BD=A3=E1=BD=BB=E1=BD=A4?= Date: Mon, 26 Feb 2024 17:27:12 +0800 Subject: [PATCH] Update the-prototype-pattern.md MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 更新错别字 --- .../object-creation/the-prototype-pattern.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/object-oriented-programming/object-creation/the-prototype-pattern.md b/docs/object-oriented-programming/object-creation/the-prototype-pattern.md index 1cdd7510c..bf1dc4cfd 100644 --- a/docs/object-oriented-programming/object-creation/the-prototype-pattern.md +++ b/docs/object-oriented-programming/object-creation/the-prototype-pattern.md @@ -102,7 +102,7 @@ Person.prototype = { } ``` -前面介绍过,没创建一个函数,就会同时创建它的原型对象,这个对象自动获得构造函数。而这里的语法,这里相当于重写了实例的原型对象,相应地原型对象中的构造函数 `constructor` 亦被覆盖,不再指向 `Person` 函数。此时,尽管 `instanceof` 操作符还能返回正确的结果,但通过 `constructor` 已经无法确定对象的类型了。 +前面介绍过,每创建一个函数,就会同时创建它的原型对象,这个对象自动获得构造函数。而这里的语法,这里相当于重写了实例的原型对象,相应地原型对象中的构造函数 `constructor` 亦被覆盖,不再指向 `Person` 函数。此时,尽管 `instanceof` 操作符还能返回正确的结果,但通过 `constructor` 已经无法确定对象的类型了。 当然,我们可以手动为它设置回适当的值。但是,以这种方式重设 `constructor` 属性回导致它的 `[[Enumerable]]` 特性被设置为 `true`。默认情况下,原生的 `constructor` 属性是不可枚举的。