on caller descriptor

Rick Waldron waldron.rick at gmail.com
Sun Apr 14 08:07:22 PDT 2013


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.

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130414/ffeebbf9/attachment-0001.html>


More information about the es-discuss mailing list