array like objects

Mike Samuel mikesamuel at gmail.com
Tue Dec 8 12:48:33 PST 2009


2009/12/8 Brendan Eich <brendan at mozilla.com>:
> On Dec 8, 2009, at 11:38 AM, Mike Samuel wrote:
>
>>> Agreed, but Erik's point here was about instanceof. Not only mutable
>>> __proto__, but mutable bindings for constructors, and the issue of
>>> multiple
>>> global objects with their unrelated suites of builtin constructors, make
>>> instanceof less than ideal for deciding "array-like".
>>
>> Ah ok.  I agree with Erik then. Even moreso, instanceof doesn't work
>> cross context.
>
> Yes (what I meant by "multiple global objects").
>
>
>>> In ES1-5, length is not enumerable for Array, String, and arguments
>>> objects.
>>> Anything array-like, same deal or it's not "like" enough.
>>
>> Maybe I'm imagining things, but I'm pretty sure that on some browsers
>> length is enumerable on arr in
>>  var arr = [1,2,3]
>>  arr.length = 2;
>
> That would be a straight-up conformance bug:
>
> js> a = [1,2]
> [1, 2]
> js> a.length
> 2
> js> for (i in a)print(i)
> 0
> 1
> js> a.length = 0
> 0
> js> for (i in a)print(i)
> js>
>
> Name names, take prisoners! Which browser(s)?

Sorry.  I can't repeat it on anything I have installed.
Maybe just a ghost of late-night-debugging-sessions past.


> /be
>


More information about the es-discuss mailing list