title: What is the purpose of the exclamation point in front of the equation with single equal sign in JavaScript?
body: <p>I found these two statements in one of the old JavaScript files.</p>
  <p><code>let expand = null, root = null;</code></p>
  <p><code>if ( !(expand = $curr_section.attr(&quot;data-expand&quot;)) ) expand = &quot;Yes&quot;;</code></p>
  <p><code>if ( root = $curr_section.attr(&quot;data-root&quot;) ) { if (root == &quot;Yes&quot;) expand = &quot;Yes&quot;;}</code></p>
  <p>I understand that <code>=</code> sign is assigning the value to the left var. However, I'm not sure what is the purpose of the <code>!</code> in front of the block? Also, why this is used inside of the <code>If ()</code> statement?</p>
  <p>If anyone can provide some explanation with better way of achieving the same goal please let me know.</p>
  <p>Thank you.</p>