Closed Bug 915669 Opened 11 years ago Closed 11 years ago

Make array methods use `this.constructor` when operating on any exotic array

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 911135

People

(Reporter: d, Unassigned)

References

()

Details

User Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:23.0) Gecko/20100101 Firefox/23.0 (Beta/Release)
Build ID: 20130814063812

Steps to reproduce:

Per the latest ES6 spec, all array methods that create new arrays (e.g. map, filter, ...) include clauses that basically boil down to: "if `this` is an exotic array object, construct the return value by doing `new this.constructor(0)`."

Currently this does not matter, because there is only one way to create exotic array objects: namely, creating arrays. But once bug #838540 is implemented, you will be able to create them by subclassing Array, or even with code like


function X() { }
X.__proto__ = Array;
X.prototype = Object.create(Array.prototype);

var x = new X();

x.filter(a => true) instanceof X; // should be true
Blocks: es6
Depends on: 838540
OS: Windows 8 → All
Hardware: x86_64 → All
Status: UNCONFIRMED → NEW
Ever confirmed: true
No longer blocks: es6
Status: NEW → RESOLVED
Closed: 11 years ago
No longer depends on: 838540
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.