Skip to content

Commit 4ab6ecb

Browse files
authored
Merge pull request #42 from IOLOII/patch-1
Update the-prototype-pattern.md
2 parents 5db9e04 + ee7a4fa commit 4ab6ecb

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/object-oriented-programming/object-creation/the-prototype-pattern.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Person.prototype = {
102102
}
103103
```
104104

105-
前面介绍过,没创建一个函数,就会同时创建它的原型对象,这个对象自动获得构造函数。而这里的语法,这里相当于重写了实例的原型对象,相应地原型对象中的构造函数 `constructor` 亦被覆盖,不再指向 `Person` 函数。此时,尽管 `instanceof` 操作符还能返回正确的结果,但通过 `constructor` 已经无法确定对象的类型了。
105+
前面介绍过,每创建一个函数,就会同时创建它的原型对象,这个对象自动获得构造函数。而这里的语法,这里相当于重写了实例的原型对象,相应地原型对象中的构造函数 `constructor` 亦被覆盖,不再指向 `Person` 函数。此时,尽管 `instanceof` 操作符还能返回正确的结果,但通过 `constructor` 已经无法确定对象的类型了。
106106

107107
当然,我们可以手动为它设置回适当的值。但是,以这种方式重设 `constructor` 属性回导致它的 `[[Enumerable]]` 特性被设置为 `true`。默认情况下,原生的 `constructor` 属性是不可枚举的。
108108

0 commit comments

Comments
 (0)