title: JavaScript error handling: can I throw an error inside a ternary operator?
body: <p>Am I allowed to throw an error inside a ternary operator? Is this valid:</p>
  
  <pre><code>function foo(params) {
  
      var msg = (params.msg) ? params.msg : (throw "error");
  
      // do stuff if everything inside `params` is defined
  }
  </code></pre>
  
  <p>What I'm trying to do is make sure all of the parameters needed, which are in a <code>param</code> object, are defined and throw an error if any one is not defined.</p>
  
  <p>If this is just foolish, is there a better approach to doing this?</p>