JavaScript return method
        Posted  
        
            by 
                user1314034
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1314034
        
        
        
        Published on 2012-04-04T23:24:46Z
        Indexed on 
            2012/04/04
            23:29 UTC
        
        
        Read the original article
        Hit count: 178
        
JavaScript
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' }
Please explain this rethult. Thank you)
© Stack Overflow or respective owner