Array.prototype.slice web-compat issue?

Allen Wirfs-Brock allen at wirfs-brock.com
Tue Sep 10 12:25:46 PDT 2013


On Sep 10, 2013, at 11:12 AM, Andrea Giammarchi wrote:

> As short answer, let me reformulate:
> AFAIK 99% of libraries out there believe that slice.call will return an Array, no matter which realm. In ES6 I see there's too much magic involved because of subclassing possibility.

Presumably this is a 100% reasonable expectation today, because that's that the ES<=5.1 specs say.  However, often do they depend upon the value being a direct instance of Array as opposed to being an instance of a subclass of an array, assuming that the subclass how all the observable characteristics of an Array instances including answering true to Array.isArray and maintaining the Array invariant. 

In other words, those libraries have never encountered a true subclass of Array.  When they do, is anything bad going to happen if the result object is also a subclass of Array?

BTW, I think it is useful to distinguish this use case from applying slice to non Array.isArray objects or using slice as a strange way to create a new Array instance.

Allen






More information about the es-discuss mailing list