Newbie query on dynamic addition of properties
<p>This is a follow-up to my previous <a href="http://stackoverflow.com/questions/12172119/javascript-how-to-avoid-addition-of-a-new-property-in-a-function/12172186">query</a>. I have been trying some code since then :</p>

<pre><code>var myFunc = function(){
    this.int1=1;
    var int2=2;
};
myFunc.int1=3;
myFunc.int3=4;

for(var name in myFunc){
    console.log('myFunc...'+name+'='+myFunc[name]);
};

var myFuncImpl = new myFunc();
myFuncImpl.int1=5;
for(var name in myFuncImpl){
    console.log('myFuncImpl...'+name+'='+myFuncImpl[name]);
};
</code></pre>

<p>And I get output as :</p>

<pre><code>myFunc...int1=3
myFunc...int3=4
myFuncImpl...int1=5
</code></pre>

<p>I can't answer the following questions :</p>

<ol>
<li><p>Why isn't <strong>int2</strong> visible as a property to myFunc ? It's still in myFunc's scope, right ? Where does this definition disappear ?</p></li>
<li><p>Why I am I able to over-write <strong>int1</strong>'s value outside function scope ? What if someone accidentally deletes my values outside code ? For "objects", I understand "Object.freeze()" can help over myFuncImpl - but what about function definitions like myFunc ?</p></li>
<li><p>Why can't I access <strong>int3</strong> from myFuncImpl ? Where did the prior definition (while defining myFunc) go ?</p></li>
</ol>

<p>I guess my doubts are due to my thinking of myFunc as a "class" (as in Java) and myFuncImpl as an object. Perhaps I am straying too far ?</p>

<p>Thanks !</p>
