Kevin Reid (2013-08-29T21:39:33.000Z)
domenic at domenicdenicola.com (2013-08-31T21:12:06.536Z)
On Thu, Aug 29, 2013 at 2:21 PM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote: > for both cases, are you using `Array.isArray` to determine that you are > operating upon an array? In both cases, all we want is the user-specified set of values, to store or operate on. So, in accordance with JavaScript idiom, we expect it to be array-like, but (since we are multi-frame code) not necessarily an `Array` from this frame. Given this, there is no particular reason to perform an `isArray` test, unless we wanted to do type checks for linting purposes ("you passed a `Foo`, not an array of `Foo`s; you probably made a mistake"), and we don't. > what would be the appropriate thing to happen (all things considered) in a world where subclasses of `Array` exist? I don't have any examples to work from; I would think there is value in *permitting* them to be used to carry the intended set-of-values if the code calling our code uses them, but I do not see how any subclass could have a custom behavior which would be *appropriate or useful* to preserve rather than discarding in these two cases, or any other case where the array being passed is used in 'functional' fashion (immediately reading as opposed to either retaining it to look at later or mutating it). (I admit I favor composition/delegation over inheritance, for public interfaces, and therefore dislike the notion of working with subclasses of concrete built-ins. But one could also consider, for example, the reasons why `java.lang.String` is final.)