diff --git a/Chapter2 - Web FrontEnd/2.43.md b/Chapter2 - Web FrontEnd/2.43.md new file mode 100644 index 0000000..76482ef --- /dev/null +++ b/Chapter2 - Web FrontEnd/2.43.md @@ -0,0 +1,21 @@ +# JS原型链与Objective-C内存布局不能说的秘密 + +## 一、原型链与 Objective-C 的秘密 +![JS 原型借鉴于 Self 语言](./../assets/2021-10-06-JSPrototype.jpg) + +![JS 属性、方法在原型链的访问](./../assets/2021-10-06-JSFunctionCallInPrototype.jpg) + +假期看了本关于 JS 的书。很多地方就是已知知识。但是看到2个地方感觉和现有知识体系有关联,蛮有意思。拍照记录了下 + +Javascript 借鉴了 Self 语言中关于原型的继承,可能会比较陌生,什么是“Self”? +看看 JS 的表现:假设从对象 O 中查询属性 X + +1. 如果 O 没有 X 这个自有属性,则会从 O 的原型对象查询属性 X +2. 如果原型对象也没有叫做 X 的自有属性,但它有自己的原型,则继续查询这个原型的原型 +3. 这个过程会不断继续,直至找到属性 X 或者查询到一个原型为 null 的对象 +可见,对象通过其 prototype 属性创建了一个用于继承属性的链条或链表。 + +其实,Self 语言由派生自 Smalltalk,也就是 Objective-C 的借鉴语言。访问 JS 对象属性、方法(找不到则从原型链上不断回溯,直到找到或者找到元类对象 null),这个特性和 OC 一模一样。 + +关于 Self 语言有2个中文 PDF可供翻阅。[SELF:简洁的威力](./selfpower-zh.pdf)、[克隆的反攻](./crpitv13noble-zh.pdf) + diff --git a/Chapter2 - Web FrontEnd/chapter2.md b/Chapter2 - Web FrontEnd/chapter2.md index 9f67aeb..c04b2f9 100644 --- a/Chapter2 - Web FrontEnd/chapter2.md +++ b/Chapter2 - Web FrontEnd/chapter2.md @@ -42,4 +42,5 @@ * [38、npm 改进之工程化](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.38.md) * [39、前端模块化演进之路](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.39.md) * [40、“Electron” 一个可圈可点的 PC 多端融合方案](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.40.md) - * [41、sourceMap 闪亮登场](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.41.md) \ No newline at end of file + * [41、sourceMap 闪亮登场](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.41.md) + * [42、JS原型链与Objective-C内存布局不能说的秘密](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.43.md) \ No newline at end of file diff --git a/Chapter2 - Web FrontEnd/crpitv13noble-zh.pdf b/Chapter2 - Web FrontEnd/crpitv13noble-zh.pdf new file mode 100644 index 0000000..c3d181d Binary files /dev/null and b/Chapter2 - Web FrontEnd/crpitv13noble-zh.pdf differ diff --git a/Chapter2 - Web FrontEnd/selfpower-zh.pdf b/Chapter2 - Web FrontEnd/selfpower-zh.pdf new file mode 100644 index 0000000..727362a Binary files /dev/null and b/Chapter2 - Web FrontEnd/selfpower-zh.pdf differ diff --git a/SUMMARY.md b/SUMMARY.md index 870d8e3..64162d1 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -142,7 +142,8 @@ * [39、前端模块化演进之路](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.39.md) * [40、“Electron” 一个可圈可点的 PC 多端融合方案](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.40.md) * [41、sourceMap 闪亮登场](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.41.md) - + * [42、JS原型链与Objective-C内存布局不能说的秘密](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter2%20-%20Web%20FrontEnd/2.43.md) + * [Chapter3 - Server](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter3%20-%20Server/chapter3.md) * [1、利用分页和模糊查询技术实现一个App接口](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter3%20-%20Server/3.1.md) * [2、网页端扫码登录实现原理](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter3%20-%20Server/3.2.md) diff --git a/assets/2021-10-06-JSFunctionCallInPrototype.jpg b/assets/2021-10-06-JSFunctionCallInPrototype.jpg new file mode 100644 index 0000000..821cd14 Binary files /dev/null and b/assets/2021-10-06-JSFunctionCallInPrototype.jpg differ diff --git a/assets/2021-10-06-JSPrototype.jpg b/assets/2021-10-06-JSPrototype.jpg new file mode 100644 index 0000000..4ca9968 Binary files /dev/null and b/assets/2021-10-06-JSPrototype.jpg differ