【发布时间】:2015-11-05 10:59:02
【问题描述】:
在Javascript中,我可以通过
获得Array对象的原型var arr_prototype = Array.prototype
据我了解,这个 Array.prototype 类似于 OOP 中的类。
在纯 OOP 语言中,Array 类可能继承自 Iterable 类,Iterable 类可能继承自 Object 类。
所以我希望通过评估表达式arr_prototype.prototype 来查看arr_prototype 的父类。
但是,它返回undefined。有人对此有想法吗?
【问题讨论】:
-
你可以得到
prototype属性,它只从function引用原型,否则你可以简单地尝试用这个名字获取属性。要从具体对象获取原型,您可以使用 Object.getPrototypeOf 函数 -
当一切都失败时,read the spec。 Array.prototype 继承自 Object.prototype,但是是 Array 的一个实例。它是一个Array exotic object,与标准的 Array 对象有点不同。
标签: javascript oop prototype prototype-programming