Dmitry Soshnikov (2013-06-25T00:21:38.000Z)
github at esdiscuss.org (2013-07-12T02:27:38.037Z)
On Mon, Jun 24, 2013 at 9:31 AM, Allen Wirfs-Brock <allen at wirfs-brock.com>wrote: > The issues (and discussion) is more complex then the above indicates. > > The root issue concerns what should Array producing methods such as Map > produce when used in an Array subclass. Should the result be an Array > instance (as it currently is in ES5) or should it be a new instance of the > subclass. If the latter, how is the actual subclass determined. If the `map` method is inherited and is called directly on the instance of the inherited class, then probably it's more logical to return the instance of the same inheriting class (i.e. the V). To answer your question how the determination of the subclass should happen -- first need to ask what is the [[NativeBrand]] says for "v" instance? Is it still "NativeArray" (shouldn't be IMO, will clarify in the spec later)? Can you use the [[NativeBrand]] check or at very least `constrcutor` property check (which though, not that safe maybe). Will it actually make sense to set the [[NativeBrand]] to the name of the class? ```js if (Array.isArray(this)) { var result = []; } else { var result = new this.constructor(<somehow_get_the_default_args>?); } ``` But again there is an issue with determination of the default arguments of the constructor, though can fallback to defaults.