Object.defineProperty cannot be used with the 'self'/'window' (i.e. global) object - by bedney

Status : 

  Fixed<br /><br />
		This item has been fixed in the current or upcoming version of this product.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

ID 605078 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 9/25/2010 4:45:42 PM
Access Restriction Public


So ECMAScript edition 5's "Object.defineProperty" works great if you've already got an object:

var foo = {}
Object.defineProperty(foo, 'bar', {value: {}, writable: false});

Now 'bar' is real (and can't be deleted from 'foo', actually - which is what I'm after here):

foo.bar -> [object Object]

But if you try to use "Object.defineProperty" with the 'self'/'window' object, nothing happens

Object.defineProperty(self, 'bar', {value: {}, writable: false});

self.bar -> undefined

The technique I'm attempting here is very, very useful when defining a library of code 'behind' a particular global variable and then making it so that library of code cannot be accidentally deleted by another scripter.
Sign in to post a comment.
Posted by Microsoft on 1/12/2012 at 6:43 AM
Thank you for your feedback.

This issue was resolved in Internet Explorer 9 released on 3/14/2011. Please verify the change and file a new feedback (or reactivate the existing one) if the problem persists.

Best regards,

The Internet Explorer Team
Posted by bedney on 11/21/2010 at 10:59 AM
This seems to have been fixed with IE9 PP7. I will attach the testcase I've been using, but it looks good!

Thanks IE team!


- Bill