Testing the existence of a method
<p>I'm trying to make some existing JS backwards compatible. I need to override a method if it does not exist, otherwise just return the existing method.</p>

<p>Here is the code I have so far:</p>

<pre><code>this.grid.getDataSource = function(){
    if (getDataSource == undefined)
        return getStore();
    else
        return getDataSource();
}
</code></pre>

<p>However it keeps returning an error on the "if" line:</p>

<blockquote>
  <p>getDataSource is undefined</p>
</blockquote>

<p>What is the best way of going about this?</p>
