Object.getPrototypeOf(arguments) VS [[Class]]

Brendan Eich brendan at mozilla.org
Wed Nov 28 09:44:23 PST 2012


Andrea Giammarchi wrote:
> null ...
>
> function isArguments(object) {
>   return -1 < {}.toString.call(object).indexOf(" Arguments]") || (
>     !!object && typeof object == "object" && !(object instanceof Object)

Sorry, this isn't right. When I wrote "ES1-3 had arguments pretending to 
be "Object" but not actually an Object instance" I did not mean 
!(argsobj instanceof Object). I meant literally that arguments instances 
are of an internal class. Kind of like proxies, because they alias 
function formal parameters.

In ES1-3 it's hard to detect an arguments object. Something like

   object instanceof Object && !object.propertyIsEnumerable('length')

(where propertyIsEnumerable includes hasOwnProperty)?

/be

>   );
> }
>
> On Wed, Nov 28, 2012 at 9:13 AM, Andrea Giammarchi 
> <andrea.giammarchi at gmail.com <mailto:andrea.giammarchi at gmail.com>> wrote:
>
>     function isArguments(object) {
>       return -1 < {}.toString.call(object).indexOf(" Arguments]") || (
>         typeof object == "object" && !(object instanceof Object)
>       );
>     }
>
>     alert([
>       isArguments({}),
>       isArguments(function(){return arguments}())
>     ]);
>
>
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss


More information about the es-discuss mailing list