I recently started experimenting with knockout and have a query. Here is an excerpt of the code:
function Task(data) {
var self = this;
self.name = ko.observable(data.name);
}
function ViewModel() {
self.taskArr = ko.observableArray([
// some default data
new Task({ name: "to-do 1"}),
new Task({ name: "to-do 2"}),
new Task({ name: "to-do 3"})
]);
Essentially, my goal is to log the contents of the object using console.log()
. However, when I try console.log(self.taskArr());
I receive [Task, Task, Task]
as output.
If I use self.taskArr()[0].name
, I am only able to fetch the first result, not all of them.