On Jun 11, 2014, at 11:09 AM, Domenic Denicola wrote:

> From: Allen Wirfs-Brock <[email protected]>
> 
>> 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


_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to