我已经弄清楚了这段代码
function getAllProperties(obj){
var result={
properties:[],
methods:[]
};
var proto = obj;
while(proto !== null){
var props = Object.getOwnPropertyNames(proto);
props.forEach(function(v){
typeof proto[v] === "function" ? result.methods.push(v) : result.properties.push(v);
});
proto = Object.getPrototypeOf(proto);
}
return result;
}
而我传入的参数是canvas上下文对象(通过canvas.getContext('2d')获取)。码字用Chrome就好了。但结果是 Firefox 得到 'Illegal operation on WrappedNative 原型对象' Error 。谁能告诉我它有什么问题?