Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
326 views
in Technique[技术] by (71.8m points)

javascript - 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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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
*/

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...