【发布时间】:2011-10-08 15:48:05
【问题描述】:
function StringStream() {}
StringStream.prototype = new Array();
StringStream.prototype.toString = function(){ return this.join(''); };
调用new StringStream(1,2,3) 会得到一个空数组
x = new StringStream(1,2,3)
给予
StringStream[0]
__proto__: Array[0]
有人可以解释为什么不调用超类的 (Array) 构造函数吗?
【问题讨论】:
-
谁给了你这个代码,为什么? :(
标签: javascript inheritance constructor superclass