Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 252
Gezim Avatar asked Nov 16 '11 19:11

Gezim


1 Answers

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
*/
like image 194
kennebec Avatar answered Oct 15 '22 15:10

kennebec