title: Is there a way to "undefine" an instance method to reveal the method defined in a prototype?
body: <p>I'm trying to wrap my head around javascript prototypes, and started to wonder if there is a way to remove/undefine an instance method defined on an object, so the method in the prototype would be called. So in the following</p>
  
  <pre><code>/* javascript */
  function Foo () {};
  Foo.prototype.myMethod = function() {alert('foo')};
  
  var foo1 = new Foo();
  var foo2 = new Foo();
  
  foo1.myMethod = function () {alert('foo changed for instance')};
  Foo.prototype.myMethod = function () {alert('foo changed in prototype')};
  
  foo1.myMethod(); // alerts 'foo changed for instance'
  foo2.myMethod(); // alerts 'foo changed in prototype'
  </code></pre>
  
  <p>Is there a way to remove <code>myMethod</code> from instance <code>foo1</code>, so that calling <code>foo1.myMethod();</code> would call the method defined in the prototype and alert "<em>foo changed in prototype</em>"?</p>
  
  <p>I guess I'm after something akin to removing a method from singleton class in Ruby, like:</p>
  
  <pre><code># ruby
  class Foo
    def myMethod
      puts "foo"
    end
  end
  
  f = Foo.new
  f.myMethod # =&gt; foo
  
  # make singleton class, re-define myMethod for this instance
  def f.myMethod
    puts "bar"
  end
  f.myMethod # =&gt; bar
  
  # remove method from singleton class
  class &lt;&lt; f
    remove_method :myMethod
  end
  f.myMethod # =&gt; foo
  </code></pre>
  
  <p>I'm asking out of sheer interest, so bonus points for practical use cases for this..</p>