From 86476130fb03b34b7ade7ba827fa4d339cf58e34 Mon Sep 17 00:00:00 2001 From: Fanrito <96723391+Fanrito@users.noreply.github.com> Date: Wed, 5 Jun 2024 10:45:47 +0800 Subject: [PATCH] =?UTF-8?q?Update:=20inherit.md=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 寄生组合式继承的代码中,输出语句console.log(person6); //{friends:"child5",name:"child5",play:[1,2,3],__proto__:Parent6},结果中的name应该为“parent6” --- docs/JavaScript/inherit.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/JavaScript/inherit.md b/docs/JavaScript/inherit.md index 353c1848..8f5b2d8d 100644 --- a/docs/JavaScript/inherit.md +++ b/docs/JavaScript/inherit.md @@ -263,7 +263,7 @@ Child6.prototype.getFriends = function () { } let person6 = new Child6(); -console.log(person6); //{friends:"child5",name:"child5",play:[1,2,3],__proto__:Parent6} +console.log(person6); //{friends:"child5",name:"parent6",play:[1,2,3],__proto__:Parent6} console.log(person6.getName()); // parent6 console.log(person6.getFriends()); // child5 ``` @@ -310,4 +310,4 @@ asuna.getName() // 成功访问到父类的方法 通过`Object.create` 来划分不同的继承方式,最后的寄生式组合继承方式是通过组合继承改造之后的最优继承方式,而 `extends` 的语法糖和寄生组合继承的方式基本类似 ## 相关链接 -https://zh.wikipedia.org/wiki/%E7%BB%A7%E6%89%BF \ No newline at end of file +https://zh.wikipedia.org/wiki/%E7%BB%A7%E6%89%BF