object literal notation - Should new be used or not
<pre><code>function foo() {
    return {a:9};
}

var bar = foo();
bar.a //returns 9
</code></pre>

<p>or</p>

<pre><code>function foo() {
    return {a:9};
}

var bar = new foo(); 
bar.a // returns 9
</code></pre>

<p>As far as I know new isnt used with the object literal notation, but how come new does work with it? Also, why is it that prototype can be accessed with new object, but not with the object literal notation?</p>

<p>edit:</p>

<p>I understand it now, if anyone else who stumbles upon this problem/question this might help you understand it:</p>

<pre><code>function foo() {
    this.a = "LOL";
    return "WTF";
};
var bar = new foo(); // bar = [Object object]
var c = foo(); // c = "WTF"
window.a // "LOL"
</code></pre>

<p>Also read the accepted answer.</p>
