From 16b32094f1051d5c151013c2d808a7d48953cbd1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=86=E5=BB=BA=E9=94=8B?= <467466356@qq.com>
Date: Mon, 7 Nov 2022 12:20:19 +0800
Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E5=8D=81=E4=B8=89=E6=AC=A1=E4=BD=9C?=
=?UTF-8?q?=E4=B8=9A?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...351\223\276&\347\273\247\346\211\277.html" | 165 ++++++++++++++++++
.../\344\275\234\344\270\232.html" | 111 ++++++++++++
.../\347\254\224\350\256\260.md" | 99 +++++++++++
3 files changed, 375 insertions(+)
create mode 100644 "39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/2022_11_04\345\216\237\345\236\213\351\223\276&\347\273\247\346\211\277.html"
create mode 100644 "39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/\344\275\234\344\270\232.html"
create mode 100644 "39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/\347\254\224\350\256\260.md"
diff --git "a/39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/2022_11_04\345\216\237\345\236\213\351\223\276&\347\273\247\346\211\277.html" "b/39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/2022_11_04\345\216\237\345\236\213\351\223\276&\347\273\247\346\211\277.html"
new file mode 100644
index 0000000..e782108
--- /dev/null
+++ "b/39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/2022_11_04\345\216\237\345\236\213\351\223\276&\347\273\247\346\211\277.html"
@@ -0,0 +1,165 @@
+
+
+
+
+
+
+
+ Document
+
+
+
+
+
+
+
\ No newline at end of file
diff --git "a/39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/\344\275\234\344\270\232.html" "b/39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/\344\275\234\344\270\232.html"
new file mode 100644
index 0000000..60ea879
--- /dev/null
+++ "b/39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/\344\275\234\344\270\232.html"
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+ Document
+
+
+
+
+
\ No newline at end of file
diff --git "a/39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/\347\254\224\350\256\260.md" "b/39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/\347\254\224\350\256\260.md"
new file mode 100644
index 0000000..e937049
--- /dev/null
+++ "b/39\351\231\206\345\273\272\351\224\213/2022-11-4\345\216\237\345\236\213\351\223\276\344\270\216\347\273\247\346\211\277/\347\254\224\350\256\260.md"
@@ -0,0 +1,99 @@
+构造函数的属性优先于原型上的属性
+ 原型重写
+ 例:
+ function Fun(){};
+ function Fun1(){};
+ Fun.prototype.name = '2'
+ var fun = new Fun();
+ Fun1.prototype = fun
+ var fun1 = new Fun1();
+ Fun1.prototype.name = '3'
+ console.log(fun.name);
+ console.log(fun1.name);
+
+ 原型链 继承:继承父类的属性和方法
+ 原型链继承:会将父级上的所有属性和方法统统继承过来:过多地继承没用的属性
+ function Grand() {} //爷爷
+ function Parent() {} //爸爸
+ function Child(){}//孩子
+ Grand.prototype.tskill = '拉二胡';
+ var grand = new Grand();
+ Parent.prototype = grand;
+ var parent = new Parent();
+ //原型重写
+ Parent.prototype.tskill = '弹琴';
+ console.log(grand.tskill);
+ console.log(parent.tskill);
+
+ 2.构造函数继承:使用call
+ function Parent(name,age){
+ this.name = name; //child.name
+ this.age = age; //child.age
+ }
+
+ function Child(name,age,sex){
+ //call
+ Parent.call(this,name,age);
+ this.sex = sex;
+ }
+ var child = new Child('张三',18,'male');
+ console.log(child.name);
+
+ 3.共享原型继承
+ function Grand(){}
+ Grand.prototype.name = '爷爷';
+
+ function Parent(){
+ }
+ Parent.prototype.name = '爹';
+ Parent.prototype.age = 40;
+
+ function Child(){
+ }
+ //名字是默认的
+ function inherit(Target,Origin){
+ Target.prototype = Origin.prototype;
+ }
+
+ inherit(Child,Parent);
+ Child.prototype.age = 100; //共享
+ var child = new Child();
+ console.log(child.age);
+
+
+
+ 4.圣杯(永恒)模式
+ function Parent() {
+ }
+ Parent.prototype.name = '爹';
+ Parent.prototype.age = 40;
+
+ function Child() {
+ }
+
+ function inherit(Target, Origin) {
+ function F(){} //临时构造函数
+ F.prototype = Origin.prototype;
+ // var f = new F();//实例化:复制一份
+ // Target.prototype = f; //独立的f,里面有父类所有的属性和方法
+ Target.prototype = new F();
+ //归位
+ //构造器归位
+ Target.prototype.constructor = Target;
+ //超类
+ Target.prototype.uber = Origin;
+
+ }
+
+ //Parent.prototype.constructor
+
+
+ inherit(Child, Parent);
+ var child = new Child();
+ console.log(child.__proto__.uber);
+ Child.prototype.name = '张三';
+ // console.log(child.name);
+ // console.log(Child.prototype.constructor);
+ // var parent = new Parent();
+ // console.log();
+ // console.log(parent.name);
\ No newline at end of file
--
Gitee