title: Setting a default variable value in a function
body: <p>I am doing a lot of front-end development and I see myself doing this a lot:</p>
  <pre><code>function doSomething(arg){
      var int = arg ? arg : 400
      //some code after
  }
  </code></pre>
  <p>So I was wondering if the was a way to do this, but shorter and cleaner (I don't like to see <code>arg</code> twice in the same line).</p>
  <p>I've seen some people doing something like that :</p>
  <pre><code>var int = arg || 400;
  </code></pre>
  <p>And since I don't know in which order I needed to place the value, I tried <code>arg || 400</code> and <code>400 || arg</code>, but it will always set <code>int</code> to the value at the right, even if <code>arg</code> is undefined.</p>
  <p>I know in PHP you can do something like <code>function doSomething(arg = 400)</code> to set a default value and in a jQuery plugin you can use <code>.extend()</code> to have default property,  but is there a short way with a single variable? Or do i have to keep using my way?</p>
  <p>Thank for any help and if you can give me resources, it would be appreciated.</p>