I have found different behavior of code when function is called / returned in different ways. It is quite confusing. So to clear my doubts I have stripped down the whole code to minumum:
Let us consider a simple function:
function f()
{
//some code
}
var objf = f();
Q1. Now objf
is undefined. Why? What does f()
returns?
function f()
{
//some code
return this;
}
var objf = f();
Q2. What does f()
returns? global object?