title: javascript constructor with optional parameters
body: <p>I am learning Javascript now and coming from the background of Java. In Java we have overloaded constructors wherein, at compile time, the compiler will decide which version of constructor to be called.</p>
  
  <p>In case of Javascript, we can have only one constructor. In this case, if the constructor has 3 arguments, how to pass only the third parameter.</p>
  
  <p>Ex: </p>
  
  <pre><code>class Addition {
   constructor(a,b,c){
     console.log(a+B+c);
   }
  }
  
  Addition obj = new Addition(null, 40, null);
  //or
  Addition onj2 = new Addition(undefined, undefined, 45);
  </code></pre>
  
  <p>Is there a better way to do this in Javascript?</p>