zoukankan      html  css  js  c++  java
  • 基于原型的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本身是需要动态类型或者弱类型的,因为“原型链”意味着一个对象的类型随时会改变,甚至一个对象的类型只能是这个对象本身。

  • 相关阅读:
    js 自动下载函数
    集群中用Memcached来实现session共享
    PDO防注入原理分析以及使用PDO的注意事项
    侧边栏
    helloworld
    angularjs 获取地址传参
    ionic 上拉加载更多&瀑布流加载&滚动到底部加载更多 主意事项
    亿级Web系统搭建——单机到分布式集群
    php 模拟表单提交
    R语言curve绘图函数
  • 原文地址:https://www.cnblogs.com/feng9exe/p/11024510.html
Copyright © 2011-2022 走看看