I'am new in javascript. I can't understand why the function returns T1 object (not just string 'hi') in the following example.
 function T1(){
    return 'hi';
 }
 function T(){
    return new T1();
}
T();
output: T1
And returns function in the following example
 function T1(){
    return function(){ return 'hi'; }
 }
 function T(){
    return new T1();
}
T();
output: function (){ return 'hi' }
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)?
Please explain this result. Thank you)
