object has no hasOwnProperty method (i.e. it's undefined) - IE8

天大地大妈咪最大 提交于 2019-12-17 07:30:11

问题


This seems quite bizarre.

Here's my experiment in the IE8 console:

typeof obj1 // "object"
obj1.hasOwnProperty // {...}

typeof obj2 // "object"
obj2.hasOwnProperty // undefined

Any ideas as to what could cause this?


回答1:


This example is from IE8, but the same return is from IE6+ and most other IE browsers.

IE before #9 does not define it for host objects

var o=window;// or document or document elements
o.hasOwnProperty

/*  returned value: (undefined)
undefined
*/


来源:https://stackoverflow.com/questions/8157700/object-has-no-hasownproperty-method-i-e-its-undefined-ie8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!