While I learn to use knockout js, I have read from various source on declaring view model as object literal and function. Generally, it came to me that the conclusion is declaring view model as function is a better choice (correct me if i am wrong).
Recently, it came to me that some member in stackoverflow use this method to declare view model instead. Though i do not know what this method call as it is not being introduced in any book or elsewhere. Hope someone can clarify what benefit of using this compare to object literal and function.
var viewModel = (function () {
var obj = {};
obj.myVariable = ko.observable();
obj.myComputed = ko.computed(function () { return "hello" + obj.myVariable() });
ko.applyBindings(obj);
return obj;
})();