ArrayClass should imply @@isConcatSpreadable

Boris Zbarsky bzbarsky at MIT.EDU
Mon Oct 28 13:20:20 PDT 2013

As far as I can tell, the two places in ES5 that test [[Class]] being 
equal to "Array" are Array.isArray() and Array.prototype.concat.

In ES6, the former does some sort of brand check, but the latter calls 
IsConcatSpreadable, which checks for a @@isConcatSpreadable symbol.

It seems to me like we should probably have ArrayClass objects return 
true from the @@isConcatSpreadable symbol.

The benefit is that this makes ArrayClass objects quack as much like an 
array as we can, I think.

The drawback is that this perhaps makes it harder to add ArrayClass to 
existing objects...

In terms of existing ArrayClass objects that are shipping on the web 
right now, Gecko is shipping (though perhaps not in final releases yet) 
the .ports of a MessageEvent and the return value of getClientRects(). 
I _think_ changing the concat() behavior of these should be OK. 
Certainly for .ports, which we haven't been shipping for very long at all.



More information about the es-discuss mailing list