Small Proposal "!in"
Michael Theriot
michael.lee.theriot at gmail.com
Wed Jul 18 15:05:24 UTC 2018
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.
Same reason we don't use...
!(a == b) // a != b
!(a === b) // a !== b
!(a > b) // a <= b
(!(a > b) && !(a == b)) // a < b
On Thursday, June 28, 2018, Tobias Buschor <tobias.buschor at 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()
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180718/01de6778/attachment.html>
More information about the es-discuss
mailing list