How can I test whether a Javascript object has a method with a given name?
<p>Consider the following sample:</p>

<pre><code>var Container = function(param) {
    this.member = param;
    var privateVar = param;
    if (!Container.prototype.stamp) {  // &lt;-- executed on the first call only
        Container.prototype.stamp = function(string) {
            return privateVar + this.member + string;
        }
    }
}

var cnt = new Container();
</code></pre>

<p>Is there any way to determine whether the object <code>cnt</code> has a method named <code>stamp</code> without knowing that it is instantiated from <code>Container</code> ? </p>

<p><img src="http://i.stack.imgur.com/jRWz4.png" alt="Another Example"></p>
