title: An explanation of && shorthand in JavaScript
body: <p>Using a watermark plugin for jQuery, I'm attempting to jslint and minimize the functions but I've come across syntax I have never seen before wherein there are expressions where there really ought to be an assignment or function call:</p>
  
  <pre><code>(function($) {
  
      $.fn.watermark = function(css, text) {
  
          return this.each(function() {
  
              var i = $(this), w;
  
              i.focus(function() {
                  w &amp;&amp; !(w=0) &amp;&amp; i.removeClass(css).data('w',0).val('');
              })
                  .blur(function() {
                      !i.val() &amp;&amp; (w=1) &amp;&amp; i.addClass(css).data('w',1).val(text);
                  })
                  .closest('form').submit(function() {
                      w &amp;&amp; i.val('');
                  });
  
              i.blur();
          });
      };
  
      $.fn.removeWatermark = function() {
  
          return this.each(function() {
  
              $(this).data('w') &amp;&amp; $(this).val('');
          });
      };
  })(jQuery);
  </code></pre>
  
  <p>I'm specifically interested in the following lines:</p>
  
  <pre><code>w &amp;&amp; !(w=0) &amp;&amp; i.removeClass(css).data('w',0).val('');
  </code></pre>
  
  <p>and</p>
  
  <pre><code>!i.val() &amp;&amp; (w=1) &amp;&amp; i.addClass(css).data('w',1).val(text);
  </code></pre>
  
  <p>Can someone explain this shorthand and rewrite these functions in such a way that I could compare them to better to understand the shorthand myself?</p>
  
  <p>Thank you.</p>