title: Alternative to try/catch for checking if a function exists in javascript
body: <p>The following statement is used because the method in question (refreshPartyList()) may not always be defined.</p>
  
  <pre><code>try {
    parent.document.getElementById("myId").contentWindow.refreshPartyList(param1, param2);
  }catch(e){}
  </code></pre>
  
  <p>Currently using the above approach and it is working fine, but is there a better alternative?</p>