File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change 77* [ 01-03] ( https://github.com/TYRMars/JSlearn#01-03 ) ` 变量类型和计算(3)-JSON的理解 `
88* [ 01-04] ( https://github.com/TYRMars/JSlearn#01-04 ) ` 原型与原型链-构造函数 `
99* [ 01-05] ( https://github.com/TYRMars/JSlearn#01-05 ) ` 原型规则和示例 `
10+ * [ 01-06] ( https://github.com/TYRMars/JSlearn#01-06 ) ` 原型链 `
1011## JS小练习
1112* JSDemo JS小程序
1213* JDMenu 京东无延迟菜单
@@ -143,6 +144,7 @@ var obj2 = obj1;
143144obj1 .x = 200 ;
144145console .log (obj2 .x ); // 200
145146```
147+ * ES中,引用类型是一种数据结构,用于将数据和功能组织在一起
146148## 01-03
147149### 变量类型和计算(3)-理解JSON
148150``` JavaScript
@@ -251,7 +253,28 @@ for (item in f) {
251253 }
252254}
253255```
254-
256+ ## 01-06
257+ ### 原型链
258+ ``` JavaScript
259+ // 构造函数
260+ function Foo (name ,age ){
261+ this .name = name;
262+ }
263+ Foo .prototype .alertName = function (){
264+ alert (this .name );
265+ }
266+ // 创建示例
267+ var f = new Foo (' zhangsan' );
268+ f .printName = function () {
269+ console .log (this .name );
270+ }
271+ // 测试
272+ f .printName ();
273+ f .alertName ();
274+ f .toString (); // 要去f.__proto__.__proto__中查找
275+ ```
276+ #### 原型链视图
277+ ![ 原型链图] ( http://www.kejiganhuo.tech/wp-content/uploads/2017/06/屏幕快照-2017-06-29-上午9.00.57.png )
255278
256279
257280---
You can’t perform that action at this time.
0 commit comments