誰能開導我,是什麼 hasOwnProperty和propertyIsEnumerable的區別是:創建一個對象實例hasOwnProperty VS propertyIsEnumerable
function f(){
this.a = 1;
this.b = 2;
this.c = function(){}
}
f.prototype = {
d : 3,
e : 4,
g : function(){}
}
:
var o = new f();
在這裏,我看不出差別。 在我看來,他們都在做同樣的事情
o.hasOwnProperty('a'); //true
o.hasOwnProperty('b'); //true
o.hasOwnProperty('c'); //true
o.hasOwnProperty('d'); //false
o.hasOwnProperty('e'); //false
o.hasOwnProperty('g'); //false
o.propertyIsEnumerable('a'); //true
o.propertyIsEnumerable('b'); //true
o.propertyIsEnumerable('c'); //true
o.propertyIsEnumerable('d'); //false
o.propertyIsEnumerable('e'); //false
o.propertyIsEnumerable('g'); //false
右鍵我,如果我錯了
這個解釋是不是接受的答案清晰。 – mareoraft