title: Assigning a default value through the logical operator OR
body: <p>We know that the javascript logical operator || produces the value of its first operand if the first operand is <em>true</em>. Otherwise, it produces the value of the second operand.</p>
  
  <p>So in this example:</p>
  
  <pre><code>&lt;script language="javascript"&gt;
  function test (value){
      this.value = value || "(value not given)";
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>if the parameter <em>value</em> passed to the function is treated as <em>false</em> like the integer <em>0</em> or the empty string <em>""</em> then <em>this.value</em> will be set to (<em>value not given)</em> which is not <s>true</s> correct (because indeed we are passing a value).</p>
  
  <p>So the question is which should be the best way to set <em>this.value</em>?</p>
  
  <p><strong>EDIT</strong>: All 4 first answers use the ternary operator "?". My question is about "||" operator.</p>