diff --git a/sxss/.keep "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/.keep" similarity index 100% rename from sxss/.keep rename to "15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/.keep" diff --git "a/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\216\237\345\236\213\347\254\224\350\256\260.md" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\216\237\345\236\213\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..f1546bc8f9ec6549e98bbb2b16c6f79245c24a20 --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\270\200\346\254\241\344\275\234\344\270\232/\345\216\237\345\236\213\347\254\224\350\256\260.md" @@ -0,0 +1,19 @@ +# 原型 + +每个构造函数都会自动生成一个prototype属性,指向一个**空对象**,这个空对象就是原型。每一个实例对象都会从原型继承属性和方法。 + +原型对象中有一个属性constructor, 它指回函数本身 + +1. 显示原型和隐式原型 + (1)每个函数function都有一个**prototype**,即显式原型(属性)(构造函数的原型) + (2)每个实例对象都有一个___**proto**___,可称为隐式原型(属性)(实例对象的原型) + (3)对象的隐式原型的值对应构造函数的显式原型的值,构造函数和实例对象之间没有直接关系 +2. 函数的prototype属性: 在定义函数时自动添加的, 默认值是一个空Object对象,对象的___**proto**___属性: 创建对象时自动添加的, 默认值为构造函数的prototype属性值 +3. 实例化:如果构造函数上与原型属性重复,优先选取构造函数的属性 +4. 函数是Function的实例 +5. Function也是个函数,它是new自身产生:Function = new Function(),所以所有函数对象的__proto__都是一样的 +6. 所有函数的显示原型prototype是new Object(),所有函数对象都是new Function()生成的 + +![](E:\JS\原型\20221026160400.jpg) + +![](E:\JS\原型\image-20221103173743080.png) \ No newline at end of file diff --git a/sxss/10.27/.keep "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/.keep" similarity index 100% rename from sxss/10.27/.keep rename to "15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/.keep" diff --git "a/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\344\275\234\344\270\232.html" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\344\275\234\344\270\232.html" new file mode 100644 index 0000000000000000000000000000000000000000..0000681b04c0c75848b0f32e1a629d5e3b4bcdeb --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\344\275\234\344\270\232.html" @@ -0,0 +1,94 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\224\350\256\260.md" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..0c1cd0fca6c4c499316ae12a8123d336aa12fad7 --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\214\346\254\241\344\275\234\344\270\232/\347\254\224\350\256\260.md" @@ -0,0 +1,39 @@ +## 原型链继承 + +通过实例化一个新的函数,子类的原型指向了父类的实例,子类就可以调用其父类原型对象上的私有属性和公有方法。(本质就是重写了原型对象) +## 构造函数继承 + +即在子类型构造函数的内部调用超类型构造函数。 +## 圣杯(永恒)模式 +注意!构造器归位 +圣杯模式的存在是用来继承已有原型对象 (A.prototype)中的成员(主要是公用方法), +同时根据自己的需求修改原型对象 (A.prototype)以定制符合我们要求的构造函数B,这个修改对已有的实例 (a1,a2,…)不会产生影响。 + +例子: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; + + } + inherit(Child, Parent); + var child = new Child(); + 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 diff --git "a/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/.keep" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/.keep" new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git "a/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/11-02-\344\270\245\346\240\274\345\207\275\346\225\260\344\275\234\344\270\232.html" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/11-02-\344\270\245\346\240\274\345\207\275\346\225\260\344\275\234\344\270\232.html" new file mode 100644 index 0000000000000000000000000000000000000000..73321fd61fa27fa4235842b0766a62e3788b33e4 --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/11-02-\344\270\245\346\240\274\345\207\275\346\225\260\344\275\234\344\270\232.html" @@ -0,0 +1,42 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/11-02-\344\270\245\346\240\274\345\207\275\346\225\260\347\254\224\350\256\260.md" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/11-02-\344\270\245\346\240\274\345\207\275\346\225\260\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..bc95c7cfd31b88af67bbe75d37d7dd83090e693d --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/11-02-\344\270\245\346\240\274\345\207\275\346\225\260\347\254\224\350\256\260.md" @@ -0,0 +1,80 @@ +第十二课:严格函数 + +​ arguments:伪数组,只有下标,长度,元素是实参的映射 + +改变this指向 + +​ // 函数被执行时,内部会产生一个this + +``` + // window.getNum(); +``` + +严格模式:防止意外发生错误时,及时抛出该错误 + +​ 1.在严格模式下,函数内部不会再意外地生成全局变量,而是抛出异常 + +例题: + +``` +function getName(a,b,a){ + 'use strict' + console.log(a); + a = 5; + + } + getName(1,3,5); + console.log(a); +``` + + + +​ 2.严格模式要求一个对象内的所有属性名在对象内必须唯一 + +例题: + +``` +"use strict" + var obj = { + a:1, + a:2, + b:4 + } + console.log(obj.a); + + function Product(name, price) { + 'use strict' + console.log(this); //null Prodcut Window + this.name = name; + this.price = price; + } +``` + +​ 3.call(null) call(undefined):严格模式下会抛出错误,非严格模式会自动转换全局 + +例题: + +``` +Product.call(undefined, '张三', 15) +``` + +​ 4.构造函数使用严格模式,必须使用new + +例题: + +``` +function Product(name, price) { + 'use strict' + this.name = name; + this.price = price; + } + new Product('张三',18); +``` + +​ 构造函数:Person( ); + +​ 普通函数小驼峰:getNameAge; + +​ 普通变量: personAge person_age; + +​ 常量:Pl \ No newline at end of file diff --git "a/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/12.html" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/12.html" new file mode 100644 index 0000000000000000000000000000000000000000..73321fd61fa27fa4235842b0766a62e3788b33e4 --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\346\254\241\344\275\234\344\270\232/12.html" @@ -0,0 +1,42 @@ + + + + + + + Document + + + + + \ No newline at end of file diff --git "a/sxss/10.27/\345\276\256\344\277\241\345\233\276\347\211\207_20221026162847.jpg" "b/sxss/10.27/\345\276\256\344\277\241\345\233\276\347\211\207_20221026162847.jpg" deleted file mode 100644 index c403f35da5ee63529573adc805d3ee0708637806..0000000000000000000000000000000000000000 Binary files "a/sxss/10.27/\345\276\256\344\277\241\345\233\276\347\211\207_20221026162847.jpg" and /dev/null differ