<div dir="ltr">`!obj.x` will return true for any falsy property - null, undefined, positive or negative zero, NaN, and the empty string. `!(x in obj)` will return true only if `x` is not an own property on `obj` nor anything in its prototype chain. They are decidedly different tests and they check for decidedly different things.</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 9, 2018 at 9:08 PM, Naveen Chawla <span dir="ltr"><<a href="mailto:naveen.chwl@gmail.com" target="_blank">naveen.chwl@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I don't use `in`.<div><br></div><div>What do I get with `'x' !in obj` or `!(x in obj)` that I don't get with !obj['x'] ?</div><div><br></div><div>Genuinely asking - I don't know what I am missing.</div><div><br></div><div>I use obj[x] because I believe it's a more familiar syntax and I believe I get the same outcome..(?)..</div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">On Mon, 9 Jul 2018 at 22:41 Steve Fink <<a href="mailto:sphink@gmail.com" target="_blank">sphink@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div class="m_-5558670505694737019m_-8954315938461140711moz-cite-prefix">+1 from me for !in. It's a surprisingly
      common nuisance.<br>
      <br>
      And I don't care for the !obj.x workaround at all -- even if you
      can survive the difference in semantics, from a code reading point
      of view this is saying something entirely different.<br>
      <br>
      And it is very different semantically. 'x' in obj does
      [[HasProperty]]; obj.x does [[GetProperty]]. With<br>
      <br>
        obj = { get x() { print("getter"); return 3; } };<br>
      <br>
      then |"x" in obj| does not print "getter" while |obj.x| does.</div></div><div bgcolor="#FFFFFF" text="#000000"><div class="m_-5558670505694737019m_-8954315938461140711moz-cite-prefix"><br>
      <br>
      On 06/29/2018 12:26 AM, Cyril Auburtin wrote:<br>
    </div></div><div bgcolor="#FFFFFF" text="#000000">
    <blockquote type="cite">
      <div dir="ltr">
        <div style="text-decoration-style:initial;text-decoration-color:initial"><br>
        </div>
        <div style="text-decoration-style:initial;text-decoration-color:initial">```js</div>
        <div style="text-decoration-style:initial;text-decoration-color:initial">
          <div style="text-decoration-style:initial;text-decoration-color:initial;font-size:12.8px;background-color:rgb(255,255,255)"><font face="monospace, monospace">if (!<span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">obj.x
                && !obj.y</span>) {<br>
            </font></div>
          <div style="text-decoration-style:initial;text-decoration-color:initial;font-size:12.8px;background-color:rgb(255,255,255)">
            <div style="text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">     doit()</font></div>
          </div>
          <div style="text-decoration-style:initial;text-decoration-color:initial;font-size:12.8px;background-color:rgb(255,255,255)"><font face="monospace, monospace">}</font></div>
          ```</div>
        <div style="text-decoration-style:initial;text-decoration-color:initial">The
          cases where they are equal to 0, '', null, undefined shouldn't
          matter imo, if for example those x and y are numbers, they
          would be defined, defaulted to 0, and you would test for `!==
          0` rather if needed</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr">Le jeu. 28 juin 2018 à 18:31, Guylian Cox <<a href="mailto:guyliancox@gmail.com" target="_blank">guyliancox@gmail.com</a>> a
          écrit :<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          <div dir="ltr">I agree, it's very annoying to have to write it
            <font face="monospace">!(x in y)</font>. I've been wanting
            this operator for a very, very long time.
            <div><br>
            </div>
            <div>If there is interest for <font face="monospace">!in</font>,
              I think <font face="monospace" size="2">!instanceof</font><font size="2"> deserves to be included too.</font></div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr">Le jeu. 28 juin 2018 à 18:19, T.J. Crowder
              <<a href="mailto:tj.crowder@farsightsoftware.com" target="_blank">tj.crowder@farsightsoftware.<wbr>com</a>>
              a écrit :<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div dir="ltr">On Thu, Jun 28, 2018 at 5:14 PM, Tobias
                Buschor <<a href="mailto:tobias.buschor@shwups.ch" target="_blank">tobias.buschor@shwups.ch</a>>
                wrote:<br>
                > I dont like to write:<br>
                > if ( !('x' in obj) &&  !('y' in obj) ) {<br>
                >      doit()<br>
                > }<br>
                ><br>
                > I was even tempted to write it that way:<br>
                > if (<span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">'x'
                  in obj  ||  'y' in obj)</span> { } else {<br>
                >      doit()<br>
                > }<br>
                <br>
              </div>
              <div dir="ltr">
                <div>There's</div>
                <div><br>
                </div>
                <div>```js</div>
                <div>
                  <div style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">if (!(<span style="font-size:small;text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">'x'
                        in obj  ||  'y' in obj)</span>) {<br>
                    </font></div>
                  <div style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial">
                    <div style="text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">     doit()</font></div>
                  </div>
                  <div style="font-size:12.8px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial"><font face="monospace, monospace">}</font></div>
                  ```</div>
                <div><br>
                </div>
                <div>That said, I've wanted <font face="monospace,
                    monospace">!in</font> many a time, in a minor sort
                  of way...</div>
              </div>
              <div dir="ltr">
                <div><br>
                </div>
                <div>-- T.J. Crowder</div>
              </div>
              ______________________________<wbr>_________________<br>
              es-discuss mailing list<br>
              <a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
              <a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/<wbr>listinfo/es-discuss</a><br>
            </blockquote>
          </div>
          ______________________________<wbr>_________________<br>
          es-discuss mailing list<br>
          <a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
          <a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/<wbr>listinfo/es-discuss</a><br>
        </blockquote>
      </div>
      <br>
      <fieldset class="m_-5558670505694737019m_-8954315938461140711mimeAttachmentHeader"></fieldset>
      <br>
      <pre>______________________________<wbr>_________________
es-discuss mailing list
<a class="m_-5558670505694737019m_-8954315938461140711moz-txt-link-abbreviated" href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a>
<a class="m_-5558670505694737019m_-8954315938461140711moz-txt-link-freetext" href="https://mail.mozilla.org/listinfo/es-discuss" target="_blank">https://mail.mozilla.org/<wbr>listinfo/es-discuss</a>
</pre>
    </blockquote>
    <p><br>
    </p>
  </div>

______________________________<wbr>_________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org" target="_blank">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/<wbr>listinfo/es-discuss</a><br>
</blockquote></div>
</div></div><br>______________________________<wbr>_________________<br>
es-discuss mailing list<br>
<a href="mailto:es-discuss@mozilla.org">es-discuss@mozilla.org</a><br>
<a href="https://mail.mozilla.org/listinfo/es-discuss" rel="noreferrer" target="_blank">https://mail.mozilla.org/<wbr>listinfo/es-discuss</a><br>
<br></blockquote></div><br></div>