Closed
Bug 911135
Opened 11 years ago
Closed 9 years ago
ES6 Array.prototype.{map, filter, slice, splice} result is based on "constructor" property
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
DUPLICATE
of bug 1165052
People
(Reporter: bbenvie, Unassigned)
References
(Blocks 1 open bug)
Details
The Array methods that return new Array instances have been changed so that return an instance of whatever their "constructor" property is, if the receiver is an actual array ("an Exotic Array Object"). If the result of Get(O, "constructor") is constructable, then it will be constructed (with the size of the resulting array as the only argument, or 0 in the case of `filter`). If the value is not constructable, then a regular array is created.
> function FakeArray(len){ this.length = len; }
> var array = [0, 1, 2];
> array.constructor = FakeArray;
> array.slice() instanceof FakeArray; // true
See ES6 spec draft (August 2013 revision) sections
* Array.prototype.slice - 15.4.3.10
* Array.prototype.splice - 15.4.3.12
* Array.prototype.map - 15.4.3.19
* Array.prototype.filter - 15.4.3.20
Comment 1•11 years ago
|
||
I doubt that that'll change anything, but we'll probably want to wait until the current discussion on es-discuss[1] has come to a conclusion. [1]: http://esdiscuss.org/topic/array-prototype-slice-web-compat-issue
Updated•11 years ago
|
Blocks: harmony:collections
Assignee | ||
Updated•10 years ago
|
Assignee: general → nobody
Comment 3•9 years ago
|
||
Bug 1165052 subsumes this, right? We'll take care of it once subclassing lands.
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → DUPLICATE
You need to log in
before you can comment on or make changes to this bug.
Description
•