title: Javascript/Jquery - Setting default value in function
body: <p>Using javascript/jquery is there a way to set a variable to a default value if no value is passed in the function? For example</p>
  
  <pre><code>function someFunction(data1,data2)
  {
  
  
  }
  </code></pre>
  
  <p>If data1 or data 2 is empty it gives me an undefined value. In php I could do just this:</p>
  
  <pre><code>function somefunction(data1 = '',data2 = '')
  {
  
  
  }
  </code></pre>
  
  <p>So if no variable is passed or data1 or data 2 it defaults to ''. In JS/Jquery do I have to check if there is a value and set it accordingly?</p>
  
  <pre><code>function someFunction(data1,data2)
  {
  
  if(!data1) {
  
  data1 = '';
  
  }
  
  if(!data2) {
  
  data2 = ''
  
  }
  
  }
  </code></pre>
  
  <p>Just seems alot needs to be done to check if variable is empty or not to give it a default value.</p>