const {resolve} = Promise; // fails

Claude Pache claude.pache at gmail.com
Thu Jul 19 13:44:20 UTC 2018



> Le 19 juil. 2018 à 13:56, Andrea Giammarchi <andrea.giammarchi at gmail.com> a écrit :
> 
> 
> Compared to every other public static method in ECMAScript that works, including those methods that might need the contextual class, as it is for the Array.from case.
> 
> ```js
> const {from} = Array;
> 
> from({0: 'abc', length: 1}); // ["abc"] // all good
> ```

That pattern falls apart when subclassing:

```js
class ImprovedArray extends Array {
	/* implementation NOT overriding the `from` static method  */
}

const {from} = ImprovedArray

from({0: 'abc', length: 1}) // Array instance instead of ImprovedArray instance
```

So, no, the `Array.from` precedent is a bad one.

—Claude



More information about the es-discuss mailing list