title: Javascript redefine and override existing function body
body: <p>I am wondering can we still change the function body once it is constructed ? </p>
  
  <pre><code>     var O = function(someValue){
             this.hello = function(){
                  return "hello, " + someValue;
             }
       }
  
       O.prototype.hello = function(){
             return "hhhhhhh";
       }
  
       var i = new O("chris");
       i.hello();   // -&gt; this still returns the old definition "hello, chris"
  </code></pre>
  
  <p>The javascript statement <code>O.prototype.hello = function(){....}</code> doesn't override and redefine the hello function behavior. Why is that ? I know it will have a type error if you tried to reuse the parameter <code>someValue</code>.</p>
  
  <pre><code>      // this will fail since it can't find the parameter 'someValue'
        O.prototype.hello = function(){
               return "aloha, " + someValue;
        } 
  </code></pre>
  
  <p>I am wondering why It allows to add function during runtime like</p>
  
  <pre><code>      O.prototype.newFunction = function(){
             return "this is a new function";
        }
  
        i.newFunction();   //  print 'this is a new function' with no problem.
  </code></pre>
  
  <p>but doesn't allow you to change the definition once it's defined.
  Did i do something wrong ? how do we override and redefine a function within a class ? and is there a way to reuse the parameter that we passed in earlier to create the object ? in this cases how do we re-use <code>someValue</code> if we want to extend more functions to it.</p>