JavaScript return method
<p>I'am new in javascript.
I can't understand why the function returns T1 object (not just string 'hi') in the following example.</p>

<pre><code> function T1(){
    return 'hi';
 }
 function T(){
    return new T1();
}
T();
</code></pre>

<p>output: T1</p>

<p>And returns function in the following example</p>

<pre><code> function T1(){
    return function(){ return 'hi'; }
 }
 function T(){
    return new T1();
}
T();
</code></pre>

<p>output: function (){ return 'hi' }</p>

<p>Why does the first example returns an object (not the string "hi", what is expected to happen) and the second returns the function body that is returned from the first function (not the expected object)? </p>

<p>Please explain this result.  Thank you)</p>
