Difference between javascript object literal notation and adding to objects
<p>Can someone explain what is happening in the code below? I'd expect toString to get called for either both foo and bar, or neither.  How is literal object notation different from adding fields to an object after it is created?</p>

<pre><code>function Obj(v) {
    this.v = v;    
};

Obj.prototype.toString= function() {
    window.alert("to string called for " +
                this.v);
    return this.v.toString();
}        

var foo = new Obj('foo');
var bar = new Obj('bar');

// toString is not called here.
var map = {foo : 'blah'};
// toString is called here.
map[bar] = "blah2";
</code></pre>

<p>Why do object literals not use toString() while adding to an existing object does use toString()?</p>

<p><a href="http://jsfiddle.net/pByGJ/2/" rel="nofollow">http://jsfiddle.net/pByGJ/2/</a></p>
