I am using Knockout.js for a rich client application and it will consist of large number of knockout.js ViewModels. In the development, I noticed two ways of creating knockout.js ViewModels. First way.
function AppViewModel() {
this.firstName = ko.observable("Bert");
this.lastName = ko.observable("Bertington");}
Second way.
var appViewModel = {
this.firstName = ko.observable("Bert"),
this.lastName = ko.observable("Bertington")};
Is there any specific difference in these two methods of declaring ViewModels? In knockout.js official page examples they have used the first way. But in third party frameworks like Knockout-validations.js has used second way. Which way should I use? Any specific advantage in using it?
I found out if I use first way, then I cant use Knockout-validations.js framework. I am really confused on this matter. Any comment is appreciated.
Thank you.