On Wed, Jul 18, 2018 at 11:05 AM Michael Theriot <
michael.lee.ther...@gmail.com> wrote:

> I think `in` and `instanceof` could both benefit from having negated
> versions.
>
> Assuming the developer is using `in` correctly, hasOwnProperty concerns
> are irrelevant. Either way they would attempt to use !(a in b), not
> !hasOwnProperty.
>

Why should we assume the developer is using `in` correctly?
Apologies if I buried my question at the end.  It was, what are the use
cases for `in` that would not be better served by an ergonomic, infix
hasOwnProperty?


Same reason we don't use...
> !(a == b) // a != b
> !(a === b) // a !== b
>


> !(a > b) // a <= b
> (!(a > b) && !(a == b)) // a < b
>

I'm not sure this is relevant to your larger point, and I've already
conceded ergonomics, but
these last two are not equivalent because NaN is weird.

a = NaN, b = 0
[!(a > b), a <= b]  // [true, false]
[!(a > b) && !(a == b), a < b]  // [true, false]





> On Thursday, June 28, 2018, Tobias Buschor <tobias.busc...@shwups.ch>
> wrote:
>
>> I dont like to write:
>> if ( !('x' in obj) &&  !('y' in obj) ) {
>>      doit()
>> }
>>
>> I was even tempted to write it that way:
>> if ('x' in obj  ||  'y' in obj) { } else {
>>      doit()
>> }
>>
>> What about a !in operator to write it like this?
>> if ('x' !in obj  &&  'y' !in obj) {
>>      doit()
>> }
>>
>> _______________________________________________
> 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

Reply via email to