W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2011

Re: What type should .findAll return

From: Jake Verbaten <raynos2@gmail.com>
Date: Fri, 11 Nov 2011 16:23:05 +0000
Message-ID: <CAMCMjp0Eb8zf5NvS0kDQSb0xUBpiHEZvLzkMcgAhffCjeL120A@mail.gmail.com>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: Jonas Sicking <jonas@sicking.cc>, Webapps WG <public-webapps@w3.org>, public-script-coord@w3.org
On Fri, Nov 11, 2011 at 3:46 PM, Tab Atkins Jr. <jackalmage@gmail.com>wrote:

> On Fri, Nov 11, 2011 at 1:05 AM, Jonas Sicking <jonas@sicking.cc> wrote:
> > And to ensure that the object acts as much as possible as an array it
> > should also have it's [[Class]] set to that of an array. This has
> > subtle effects on a number of functions. For example it affects what
> > Object.toString() and Array.isArray returns, it affects how
> > Array.concat behaves, and it affects the JSON serializer.
>
> Could you point me to an explanation of what [[Class]] represents in
> ecmascript?  It's a little hard to search for.
>

[[Class]] is simply an internal property
<http://es5.github.com/#x8.6.2>containing a string like "Array",
"String", "Object", etc. It's mainly
used throughout the ES specification to determine how internal methods
should behave to inputs.

For example JSON.parse <http://es5.github.com/#x15.12.2> checks for the
[[Class]] of Array and adjusts the output accordingly. A quick string
search on "Array" will find you all occurrences of the internals relying on
[[Class]] being set to "Array"


>
>
> > Another way to fix this problem would be to change the definition of
> > Array.prototype.filter, but I have no idea if that's doable, or how
> > that would be done.
>
> I prefer this if possible.
>
>
> > What do people think?
>
> +1
>
> ~TJ
>
>
Received on Friday, 11 November 2011 16:23:35 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 8 May 2013 19:30:04 UTC