Array {
max: function(){
var i, max = this[0];
for (i = 1; i < this.length; i++){
if (max < this[i])
max = this[i];
}
return max;
}
}var x = new Array(1, 2, 3, 4, 5, 6);
var y = x.max();// 为什么不对

解决方案 »

  1.   

    All intrinsic JScript objects have a prototype property that is read-only. Functionality may be added to the prototype, as in the example, but the object may not be assigned a different prototype内置类型的prototype是只读的。好好看上面这段话吧。
      

  2.   

    楼上懂得真多,是说max()是内置类型,不能改是吗
      

  3.   

    使用方法不对,第一种你把整个Array.prototype都改了,第二种只添加一个方法