title: Javascript: can't override toString method in very simple class?
body: <p>I'm trying to override the 'toString' method in a very simple class.  I've tried multiple approaches, but am not getting the output I would expect</p>
  
  <pre><code>function foo(arg){
      this.n=20;
      this.x=arg;
  }
  
  foo.prototype.toString = function(){
      return this.x.toString();
  };
  
  c = new foo(5);
  
  console.log(c);
  </code></pre>
  
  <p>I expect to see the output as "5" but instead the output I get is the default "{ n:20, x:5 }"</p>
  
  <p>What am  I doing wrong? </p>