如果我错过了一些明显的东西,我不会这样做,但是当我做下面的事情时: -
Object.prototype.inherit = function(fromClass) {
fromClass.apply(this, Array.prototype.slice.call(arguments, 1));
for(var key in fromClass.prototype){
if(typeof fromClass.prototype[key] == 'function')
this.prototype[key] = fromClass.prototype[key];
}
};
然后我再也无法处理任何物体了。我总是不明确。类似的当我尝试将一些方法“注入”Array.prototype
时,阵列就会停止工作!我使用的是Firefox 4.0.1。
我错过了什么吗?
答案 0 :(得分:1)
请,请,请, 请 不要扩展OBJECT.PROTOTYPE。
谢谢。
现在回答你的问题,你的意思是你不能再使用对象?你打算打破for-in循环,但缺少一切应该仍然有用。