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

RESOLVED DUPLICATE of bug 911135

Status

()

Core
JavaScript Engine
RESOLVED DUPLICATE of bug 911135
4 years ago
4 years ago

People

(Reporter: Domenic Denicola, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

4 years ago
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
(Reporter)

Updated

4 years ago
Blocks: 694100
Depends on: 838540
OS: Windows 8 → All
Hardware: x86_64 → All

Updated

4 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true

Updated

4 years ago
No longer blocks: 694100
Status: NEW → RESOLVED
Last Resolved: 4 years ago
No longer depends on: 838540
Resolution: --- → DUPLICATE
Duplicate of bug: 911135
You need to log in before you can comment on or make changes to this bug.