1var viewModel = {
2 firstName : ko.observable("Bert"),
3 lastName : ko.observable("Smith"),
4 pets : ko.observableArray(["Cat", "Dog", "Fish"]),
5 type : "Customer"
6};
7viewModel.hasALotOfPets = ko.computed(function() {
8 return this.pets().length > 2
9}, viewModel)
10