Javascript 对象没有 hasOwnProperty 方法(即未定义)- IE8
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8157700/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 04:55:08 来源:igfitidea点击:
object has no hasOwnProperty method (i.e. it's undefined) - IE8
提问by Gezim
This seems quite bizarre.
这看起来很奇怪。
Here's my experiment in the IE8 console:
这是我在 IE8 控制台中的实验:
typeof obj1 // "object"
obj1.hasOwnProperty // {...}
typeof obj2 // "object"
obj2.hasOwnProperty // undefined
Any ideas as to what could cause this?
关于什么可能导致这种情况的任何想法?
回答by kennebec
This example is from IE8, but the same return is from IE6+ and most other IE browsers.
这个例子来自 IE8,但同样的返回来自 IE6+ 和大多数其他 IE 浏览器。
IE before #9 does not define it for hostobjects
#9 之前的 IE 没有为宿主对象定义它
var o=window;// or document or document elements
o.hasOwnProperty
/* returned value: (undefined)
undefined
*/

