Allen Wirfs-Brock (2014-06-11T18:44:19.000Z)
On Jun 11, 2014, at 11:09 AM, Domenic Denicola wrote:

> From: Allen Wirfs-Brock <allen at wirfs-brock.com>
> 
>> There are a few uses of IsConstructor in some Array methods that deal with subtle backwards compat issues that are a result of extending Array to be subclassable.  These are very unique cases and I don't think you should look at them as establishing a pattern that should be followed in other situations.
> 
> Can you expand on these a bit more? What would happen if they threw when used on non-constructors?
> 

Here is some ES5 code that would fail if the IsConstructor test in map threw for a non-constructor:

var o = [];
o.constructor = undefined;
o.map(function(){}) instanceof Array
/*
true
*/

We're already walking a compatibility tight-rope to make sure that:

class SubA extends Array {};
( new SubA).map(x=>x) instanceof SubA   //true in ES6, would have been false in ES5

It's hard to say where we need to maintain strict backwards compatibility and where we can diverge to support new functionality but an over-riding ES6 guideline has been to bend backwards to minimize breaking changes.

Allen
domenic at domenicdenicola.com (2014-06-20T19:26:58.511Z)
Here is some ES5 code that would fail if the IsConstructor test in map threw for a non-constructor:

```js
var o = [];
o.constructor = undefined;
o.map(function(){}) instanceof Array
/*
true
*/
```

We're already walking a compatibility tight-rope to make sure that:

```js
class SubA extends Array {};
( new SubA).map(x=>x) instanceof SubA   //true in ES6, would have been false in ES5
```

It's hard to say where we need to maintain strict backwards compatibility and where we can diverge to support new functionality but an over-riding ES6 guideline has been to bend backwards to minimize breaking changes.