Re: Array.prototype.sort( callbackfn [ , thisArg ] )

2019-11-12 Thread Michaël Rouges
About arrow functions/binding, it's just a principle, I try to never create
some function on-the-fly, I'm working only by immutable objects derivation.

But, ok, if no choice, I'll do that. ;)
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Array.prototype.sort( callbackfn [ , thisArg ] )

2019-11-11 Thread Jordan Harband
What's the issue with creating a new function for that case, that accesses
the other list in its closure?

(Arrow functions, or .bind, are cheap; the `thisArg` makes it basically
impossible to add extra args to all functions that have it, and is almost
never used)

On Mon, Nov 11, 2019 at 11:03 PM Michaël Rouges 
wrote:

> For example, to easily sort the values, compared with another list, using
> only one iteration.
>
> Le mar. 12 nov. 2019 à 07:42, Jordan Harband  a écrit :
>
>> I'd assume it's because sort predates ES5, when the thisArg was added;
>> and also because a well-behaved comparator only operates based on `a` and
>> `b` - why would you need a receiver?
>>
>> On Mon, Nov 11, 2019 at 7:34 PM Michaël Rouges 
>> wrote:
>>
>>> Hi all,
>>>
>>> Is there a reason to not have a `thisArg ` for the
>>> `Array.prototype.sort()` callback?
>>>
>>> Actually, it enforces to bind the context or to have nested functions,
>>> each one creating a new function where it isn't strictly necessary.
>>>
>>> Michaël Rouges - https://github.com/Lcfvs - @Lcfvs
>>> ___
>>> es-discuss mailing list
>>> es-discuss@mozilla.org
>>> https://mail.mozilla.org/listinfo/es-discuss
>>>
>> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Array.prototype.sort( callbackfn [ , thisArg ] )

2019-11-11 Thread Michaël Rouges
For example, to easily sort the values, compared with another list, using
only one iteration.

Le mar. 12 nov. 2019 à 07:42, Jordan Harband  a écrit :

> I'd assume it's because sort predates ES5, when the thisArg was added; and
> also because a well-behaved comparator only operates based on `a` and `b` -
> why would you need a receiver?
>
> On Mon, Nov 11, 2019 at 7:34 PM Michaël Rouges 
> wrote:
>
>> Hi all,
>>
>> Is there a reason to not have a `thisArg ` for the
>> `Array.prototype.sort()` callback?
>>
>> Actually, it enforces to bind the context or to have nested functions,
>> each one creating a new function where it isn't strictly necessary.
>>
>> Michaël Rouges - https://github.com/Lcfvs - @Lcfvs
>> ___
>> es-discuss mailing list
>> es-discuss@mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss


Re: Array.prototype.sort( callbackfn [ , thisArg ] )

2019-11-11 Thread Jordan Harband
I'd assume it's because sort predates ES5, when the thisArg was added; and
also because a well-behaved comparator only operates based on `a` and `b` -
why would you need a receiver?

On Mon, Nov 11, 2019 at 7:34 PM Michaël Rouges 
wrote:

> Hi all,
>
> Is there a reason to not have a `thisArg ` for the
> `Array.prototype.sort()` callback?
>
> Actually, it enforces to bind the context or to have nested functions,
> each one creating a new function where it isn't strictly necessary.
>
> Michaël Rouges - https://github.com/Lcfvs - @Lcfvs
> ___
> es-discuss mailing list
> es-discuss@mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
___
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss