基于原型的js语言

基于原型编程首先要考虑的问题:原型与对象的关系;php

 

使用原型概念创建基于复用目的的联系链,以供运行时系统使用。html

 

1、原型系统原理编程

 

封装、原型、多态 vs 封装、继承、多态ui

 

引用原型 vs 复制原型 机制this

 

原型系统的复制操做,有两种实现思路,一个是并不真的去复制一个原型对象,而是使得新对象持有一个原型的引用,另外一个是切实地复制对象,今后两个对象再无关联。历史上的基于原型语言所以产生了两个流派,显然,JavaScript 显然选择了前一种方式。spa

 

https://www.zhihu.com/question/54870785;prototype

 

2、原型及原型链构建htm

 

 

3、运行时对象

 

Delegation[edit]blog

In prototype-based languages that use delegation, the language runtime is capable of dispatching the correct method or finding the right piece of data simply by following a series of delegation pointers (from object to its prototype) until a match is found. All that is required to establish this behavior-sharing between objects is the delegation pointer. Unlike the relationship between class and instance in class-based object-oriented languages, the relationship between the prototype and its offshoots does not require that the child object have a memory or structural similarity to the prototype beyond this link.

 

https://www.cnblogs.com/feng9exe/p/8289967.html

 

4、动态语言

 

http://www.cnblogs.com/Proteas/archive/2013/03/11/2953915.html

 

class based自己是对类型系统更友好的,而prototype based自己是须要动态类型或者弱类型的,由于“原型链”意味着一个对象的类型随时会改变,甚至一个对象的类型只能是这个对象自己。

相关文章
相关标签/搜索