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

前端 未结 1 1512
时光取名叫无心
时光取名叫无心 2020-11-30 08:40

This seems quite bizarre.

Here\'s my experiment in the IE8 console:

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

typeof obj2 // \"object\"         


        
相关标签:
1条回答
  • 2020-11-30 09:17

    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
    */
    
    0 讨论(0)
提交回复
热议问题