這似乎很奇怪。object has no hasOwnProperty method(ie it undefined) - IE8
這裏是我的實驗在IE8控制檯:
typeof obj1 // "object"
obj1.hasOwnProperty // {...}
typeof obj2 // "object"
obj2.hasOwnProperty // undefined
任何想法,這是什麼原因?
這似乎很奇怪。object has no hasOwnProperty method(ie it undefined) - IE8
這裏是我的實驗在IE8控制檯:
typeof obj1 // "object"
obj1.hasOwnProperty // {...}
typeof obj2 // "object"
obj2.hasOwnProperty // undefined
任何想法,這是什麼原因?
本例來自IE8,但IE6 +和大多數其他IE瀏覽器的返回值相同。
IE之前#9不限定它主機對象
var o=window;// or document or document elements
o.hasOwnProperty
/* returned value: (undefined)
undefined
*/
是OBJ2一個宿主對象?你在IE7/IE8 /怪癖模式? – Raynos
關於'本地對象和宿主對象之間的區別?':http://stackoverflow.com/questions/7614317/what-is-the-difference-between-native-objects-and-host-objects –
相關http:// stackoverflow.com/questions/135448/how-do-i-check-to-see-if-an-object-has-a-property-in-javascript –