File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed
Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 88* [ 01-04] ( https://github.com/TYRMars/JSlearn#01-04 ) ` 原型与原型链-构造函数 `
99* [ 01-05] ( https://github.com/TYRMars/JSlearn#01-05 ) ` 原型规则和示例 `
1010* [ 01-06] ( https://github.com/TYRMars/JSlearn#01-06 ) ` 原型链 `
11+ * [ 01-07] ( https://github.com/TYRMars/JSlearn#01-07 ) ` instanceof `
12+ * [ 01-08] ( https://github.com/TYRMars/JSlearn#01-08 ) ` 知识点小结 & 解决问题 `
13+
14+
1115## JS小练习
1216* JSDemo JS小程序
1317* JDMenu 京东无延迟菜单
1418* DatePicker组件开发
1519* 手风琴效果开发
20+
1621## 知识点学习
1722## 01-01
1823### 变量类型和计算(1)
@@ -276,6 +281,45 @@ f.toString(); // 要去f.__proto__.__proto__中查找
276281#### 原型链视图
277282![ 原型链图] ( http://www.kejiganhuo.tech/wp-content/uploads/2017/06/屏幕快照-2017-06-29-上午9.00.57.png )
278283
284+ ## 01-07
285+ ### instanceof
286+ * 用于判断` 引用类型 ` 属于哪个` 构造函数 ` 的方法
287+ * ` f instanceof Foo ` 的判断逻辑是:
288+ * ` f ` 的` __proto__ ` 一层一层往上走,是否能对应到` Foo.prototype `
289+ * 再试着判断f instanceof Object
290+
291+ ## 01-08
292+ ### 知识点小结 & 解决问题
293+ * 如何准确判断一个变量是数组类型
294+ ``` JavaScript
295+ var arr = [];
296+ arr instanceof Array ; // true
297+ typeof arr // object typeof是无法判断是否是数组
298+ ```
299+ * 写一个原型链继承的例子
300+ ``` JavaScript
301+ // 动物
302+ function Animal (){
303+ this .eat = function () {
304+ console .log (' animal eat' );
305+ }
306+ }
307+ // 狗🐶
308+ function Dog (){
309+ this .bark = function () {
310+ console .log (' dog bark' );
311+ }
312+ }
313+ Dog .prototype = new Animal ();
314+ // 哈士奇
315+ var hashiqi = new Dog ();
316+ // 如果要真正写,就要写更贴近实战的原型链
317+ ```
318+ * 推荐 阮一峰老师👨🏫的两篇文章:[ Javascript 面向对象编程(一):封装] ( http://www.ruanyifeng.com/blog/2010/05/object-oriented_javascript_encapsulation.html ) 、[ Javascript继承机制的设计思想] ( http://www.ruanyifeng.com/blog/2011/06/designing_ideas_of_inheritance_mechanism_in_javascript.html )
319+
320+ * 描述new一个对象的过程
321+ * zepto(或其他框架)源码中如何使用原型链
322+
279323
280324---
281325
You can’t perform that action at this time.
0 commit comments