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

Andrea Giammarchi andrea.giammarchi at gmail.com
Wed Nov 28 09:13:26 PST 2012


So the check to know if an object is Arguments cross version would be like
this, correct?

function isArguments(object) {
  return -1 < {}.toString.call(object).indexOf(" Arguments]") || (
    typeof object == "object" && !(object instanceof Object)
  );
}

alert([
  isArguments({}),
  isArguments(function(){return arguments}())
]);

Thanks



On Wed, Nov 28, 2012 at 8:59 AM, Brendan Eich <brendan at mozilla.org> wrote:

> ES1-3 had arguments pretending to be "Object" but not actually an Object
> instance.
>
> ES5 changed to use an internal class with name "Arguments". No Arguments
> constructor, Arguments.prototype, etc.
>
> I don't think we should polish the arguments turd further.
>
> /be
>
> Andrea Giammarchi wrote:
>
>> I just wonder if anyone can explain why functions arguments [[Class]] is
>> Arguments but Object.getPrototypeOf(**arguments) is Object.prototype
>>
>> This looks to me inconsistent against every other [[Class]] different
>> from Object case:either the class Arguments exists, or it doesn't, don't
>> you think?
>>
>> !function(){
>> Object.getPrototypeOf(**arguments) == Object.prototype; // true
>> {}.toString.call(
>>   Object.getPrototypeOf(**arguments)
>> ) == {}.toString(); // true again
>> }();
>>
>> Thanks for clarifications.
>> ______________________________**_________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121128/0b0edf35/attachment.html>


More information about the es-discuss mailing list