基于原型的js语言

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

 

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

 

一、原型系统原理

 

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

 

引用原型 vs 复制原型 机制

 

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

 

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

 

二、原型及原型链构建

 

 

三、运行时

 

Delegation[edit]

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

 

四、动态语言

 

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

 

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

转载于:https://www.cnblogs.com/feng9exe/p/11024510.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值