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\270\211\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\270\211\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\211\346\254\241\344\275\234\344\270\232/\345\216\237\345\236\213\351\223\276\347\273\247\346\211\277.md" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/\345\216\237\345\236\213\351\223\276\347\273\247\346\211\277.md" new file mode 100644 index 0000000000000000000000000000000000000000..f86f6fe1c2f7679d20cb4683bfb318b48f8aa716 --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\270\211\346\254\241\344\275\234\344\270\232/\345\216\237\345\236\213\351\223\276\347\273\247\346\211\277.md" @@ -0,0 +1,71 @@ +原型链继承 + +​ 父类中新增的实例和子类的都可以使用 +​ 可以在子类中增加实例属性,如果要新增加原型属性和方法需要在new 父类构造函数 的后面 + +例子 + +​ // function Father(){ +​ // this.say = function(){ +​ // console.log('父类'); +​ // } +​ // }; +​ // function Son(){}; +​ // Son.prototype = new Father(); +​ // var son = new Son(); +​ // son.say(); + +构造函数继承 + + 构造函数继承 + +例子 + +​ //方法都在构造函数里,不能继承原型的属性和方法,只能继承父类的实例属性和方法 +​ // function Father(){ +​ // this.say = function(){ +​ // console.log('这是父类'); +​ // } +​ // }; +​ // Father.prototype.name = '呼呼'; +​ // function Son(){ +​ // Father.call(this); +​ // }; +​ // var son = new Son(); +​ // son.say();//这是父类 +​ // console.log(son.prototype.name);//Uncaught TypeError: Cannot read properties of undefined (reading 'name') + +共享原型继承 + +例子 + +// function Father(){}; + // function Son(){}; + // function inherit(Target,Origin){ + // Target.prototype = Origin.prototype; + // } + // inherit(Son,Father); + // Father.prototype.age = 25; + // Son.prototype.age = 10; + // console.log(Father.prototype.age);//10 + // console.log(Son.prototype.age);//10 + +圣杯模式 + +例子 + + // function Father(){}; + // function Son(){}; + // function inherit(Target,Origin){ + // function F(){}; + // F.prototype = Origin.prototype; + // Target.prototype = new F(); + // Target.prototype.constructor = Target; + // Target.prototype.uber = Origin; + // } + // inherit(Son,Father); + // Father.prototype.age = 25; + // Son.prototype.age = 10; + // console.log(Father.prototype.age); + // console.log(Son.prototype.age); + 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/.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" 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\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\344\272\224\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\344\272\224\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\344\272\224\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\224\346\254\241\344\275\234\344\270\232/\344\275\234\344\270\232.html" new file mode 100644 index 0000000000000000000000000000000000000000..94b7e3ef848156d54d11c5cd871ffb702e1f1b49 --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\224\346\254\241\344\275\234\344\270\232/\344\275\234\344\270\232.html" @@ -0,0 +1,103 @@ + + + + + + + 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\224\346\254\241\344\275\234\344\270\232/\345\274\202\345\270\270.md" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\224\346\254\241\344\275\234\344\270\232/\345\274\202\345\270\270.md" new file mode 100644 index 0000000000000000000000000000000000000000..019da27845ced4716cb930dd6e11efc067f39786 --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\344\272\224\346\254\241\344\275\234\344\270\232/\345\274\202\345\270\270.md" @@ -0,0 +1,13 @@ +# 异常 + +**try……catch用于语法错误**,错误(error)有name和message两个属性。 +**throw用于逻辑错误**。 + +对于逻辑错误,js是不会抛出异常的,也就是说,用try catch没有用。这种时候,需要自己创建error对象的实例,然后用throw抛出异常 + +## try.....catch + + + +## throw + diff --git "a/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\345\233\233\344\275\234\344\270\232\346\255\243\345\210\231/.keep" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\345\233\233\344\275\234\344\270\232\346\255\243\345\210\231/.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\345\233\233\344\275\234\344\270\232\346\255\243\345\210\231/\346\255\243\345\210\231\344\275\234\344\270\232.html" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\345\233\233\344\275\234\344\270\232\346\255\243\345\210\231/\346\255\243\345\210\231\344\275\234\344\270\232.html" new file mode 100644 index 0000000000000000000000000000000000000000..702806fcddbcc27cfa5bc12f05dbb501ff716ad7 --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\345\233\233\344\275\234\344\270\232\346\255\243\345\210\231/\346\255\243\345\210\231\344\275\234\344\270\232.html" @@ -0,0 +1,29 @@ + + + + + + + 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\345\233\233\344\275\234\344\270\232\346\255\243\345\210\231/\346\255\243\345\210\231\347\254\224\350\256\260.md" "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\345\233\233\344\275\234\344\270\232\346\255\243\345\210\231/\346\255\243\345\210\231\347\254\224\350\256\260.md" new file mode 100644 index 0000000000000000000000000000000000000000..16b4839eab76eaccbc501bc84cf55b9b09b81ad8 --- /dev/null +++ "b/15\351\231\210\347\253\213\346\231\272/\347\254\254\345\215\201\345\233\233\344\275\234\344\270\232\346\255\243\345\210\231/\346\255\243\345\210\231\347\254\224\350\256\260.md" @@ -0,0 +1,109 @@ +# 正则 + +正则:用来处理(匹配)字符串的;正则是单独一套语法体系; + +元字符:在正则当中有特殊语义的字符: . [] [^] ? * + {min,max} ^ $ () \1\2 | + +字符组:在固定范围内匹配一个 + +\d[0-9] \w[0-9A-Za-z_] \s[\f\n\r\t] + +.(除了转义) + +贪婪模式:能多就多 + +非贪婪模式:在正则后加?,能少就少 + +## **1.单个数字和字符的元字符** + +[范围] :匹配单个范围内的字符 +[0-9]: 匹配单个数字0-9 +[a-zA-Z0-9_] :匹配单个的数字、字母下划线 +[ ^a-z ]:匹配任意一个除括号范围内的字符 +[ ^0-9 ]:匹配任意一个非数字字符 +\w :匹配单个的数字、字母下划线 等价于 [a-zA-Z0-9] +\W :匹配单个非数字、字母下划线 +\d :匹配单个数字 等价于 [0-9] +\D :匹配单个非数字 等价于 [ ^0-9 ] + +## 2.重复匹配字符 + +x {m,n}:匹配m到n个x字符 + +x{m,}:匹配最少m个最多无限x字符 + +x{m}:必须匹配m个x字符 + +x+:匹配最少1个字符 + +x*:匹配任意x字符 + +x?:匹配0个或1个x字符 + + + +## 3.锚字符 + +^x:以x字符开头 + +x$:以x字符结尾 + +## 4.空白字符 + +\s:匹配单个空白字符 + +\S:匹配单个非空白字符 + +## 5.修饰符(没有先后顺序) + +/x/i 忽略大小写 +/x/g 全局匹配(查找所有匹配而非在找到第一个匹配后停止) +/x/m 换行匹配 + +## 6.方法test,exec + +### (1)test + +格式:正则.test(变量) + +功能:在字符串中匹配正则是否存在,有返回true,无返回false + +### (2)exec + +格式:正则.exec(变量) + +功能:在字符串中匹配正则是否存在,有返回一个数组,无返回null + +## 7.正则的字符串函数match,search,replace,split + +### match + +格式:字符串.match(正则) +功能:在字符串中匹配这个正则是否存在,**有返回**一个数组,数组放着匹配到的子串,**无返回**null + +### search + +格式:字符串.search(正则) + +功能:在字符串中,查找正则表达式,**第一次出现的位置**,**有返回**查找到的下标,**无返回**-1 + +### replace + +格式:字符串.replace(正则,替换的字符串) + +功能:在字符串找到正则,把他替换成新字符串,返回替换成功的字符串 + +### split + +格式:字符串.split(正则) + +功能:使用正则对字符串进行分割,返回分割后的数组 + + + + + + + + + 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