It is beginning with
new myAppViewModel part...
new
in JavaScript is looks like a keyword but actually an
operator
!!! As any operator also new has to return a value!
What actually
new
does is calling the function you gave him as parameter - and yes, this is a function even you like to think it as a class (in fact in JavaScript there is no difference more than semantics)...
In the normal JavaScript environment you would create myAppViewModel without the envelop that knockout.js requires, like this:
function myAppViewModel() {
this.myName = 'Sudheer';
}
In this case new operator was able to create a new class out of the function without return too, but in knockout.js you enclose your function/class inside an other function/class (define it called) you have to explicitly return the correct answer to new...
That's the reason it will not work without return at the beginning...