File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -166,14 +166,17 @@ JSON.parse('{"a":10."b":20}')
166166* 原型链
167167* instanceof
168168#### 构造函数
169+ * 普通的函数就像是按步骤执行的动作,而构造函数更像是可更改零件的木偶,普通函数可以直接调用,但是构造函数需要new
170+ * 因为构造函数也是函数,所以可以直接被调用,但是它的返回值为undefine,此时构造函数里面的this对象等于全局this对象
171+ * 扩展` 实例和对象的区别,从定义上来讲:1、实例是类的具象化产品,2、而对象是一个具有多种属性的内容结构。 `
169172``` JavaScript
170173funciton Foo (name ,age ){
171174 this .name = name;
172175 this .age = age;
173176 this .class = ' class-1' ;
174177 // return this //默认有这一行
175178}
176- var f = new Foo (' zhangsan' ,20 );
179+ var f = new Foo (' zhangsan' ,20 ); // 实例化对象
177180// var f1 = new Foo('lisi',22) //创建多个对象
178181```
179182#### 构造函数-扩展
@@ -185,6 +188,7 @@ var f = new Foo('zhangsan',20);
185188
186189## 01-05
187190### 原型规则和示例
191+ *
188192* 5条原型规则
189193* 原型规则是学习原型链的基础
190194* 所有的引用类型(数组、对象、函数),都具有对象特质、即可自由扩展属性(除了“NULL”以外)
@@ -202,6 +206,21 @@ console.log(obj.__proto__);
202206console .log (arr .__proto__ );
203207console .log (fn .__proto__ );
204208```
209+ #### ` prototype `
210+ * ` prototype ` 解释为JavaScript开发函式库及框架
211+ * 所有的函数,都有一个` prototype ` (显示原型)属性,属性值也是一个普通对象。
212+ ``` JavaScript
213+ console .log (fn .prototype );
214+ ```
215+ #### ` __proto__ ` 与` prototype `
216+ * 所有引用类型(数组、对象、函数),` __proto__ ` 属性值指向它的构造函数的` prototype ` 属性值
217+ ``` JavaScript
218+ console .log (obj .__proto__ === Object .prototype );
219+ ```
220+ * 当试图得到一个对象的某个属性时,如果这个对象本身没有这个属性,那么会去它的` __proto__ ` (即它的构造函数` prototype ` )中寻找
221+
222+
223+
205224---
206225
207226### JSDemo JS小程序
You can’t perform that action at this time.
0 commit comments