Javascript: 'this' changes when assigning a property?
<p>I know 'this' can be a problem when you don't understand Javascript well but this one got me a little puzzled.</p>

<pre><code>var ControlTypes = {
    TextBox: function () {
        console.log(this);
        this.Name = "TextBox";
        console.log(this);
    }
}

ControlTypes.TextBox();
</code></pre>

<p>Firebug gives the following result:</p>

<pre><code>Object {}
Object { Name="TextBox"}
</code></pre>

<p>The first object is ControlTypes and the second one is Textbox. Could anybody explain the behavior behind this?</p>
