on caller descriptor
On Sunday, April 14, 2013, Andrea Giammarchi wrote:
I wonder if all of this is expected:
(function(){ "use strict"; function caller() { alert(caller.caller); } // error if invoked: caller(); // but showing up in properties var properties = Object.getOwnPropertyNames(caller); if (properties.indexOf('caller')) { console.log(JSON.stringify( Object.getOwnPropertyDescriptor(caller, 'caller') )); // will show // enumerable: false, configurable: false } }());
same is for arguments ... so fn.arguments is there too
Am I the only one thinking this is confusing ?
I understand it's convenient for engines to simply put such descriptor there but shouldn't these properties be hidden under use strict?
Just wondering, thanks for any clarification.
This is what is meant by "poisoned". The properties are there, because the spec says they should be, but accessing them results in a thrown exception.
generalizing means that for any generic object we should try/catch to avoid that error ? talking about automated code ... the "whitelist" is everyday bigger :)
Thanks for the answer
I wonder if all of this is expected:
(function(){ "use strict"; function caller() { alert(caller.caller); } // error if invoked: caller(); // but showing up in properties var properties = Object.getOwnPropertyNames(caller); if (properties.indexOf('caller')) { console.log(JSON.stringify( Object.getOwnPropertyDescriptor(caller, 'caller') )); // will show // enumerable: false, configurable: false } }());
same is for
arguments
... sofn.arguments
is there tooAm I the only one thinking this is confusing ?
I understand it's convenient for engines to simply put such descriptor there but shouldn't these properties be hidden under use strict?
Just wondering, thanks for any clarification.