I'm using knockout js to create a list with a search function.
Result of the console.log:
As you can see the array supposedly has 5 objects in it but then the proto has 0. I don't understand what might be wrong.
var iniList = [
new Spot("Park"),
new Spot("High School"),
new Spot("Soccer Stadium"),
new Spot("Railway Station"),
new Spot("Hospital")
];
var viewModel = {
spots: ko.observableArray(iniList),
filter: ko.observable(''),
search: function(value) {
console.log(iniList);
viewModel.spots.removeAll();
for (x = 0; x < iniList.length; x++) {
console.log("iniList[x]");
if (iniList[x].name.toLowerCase().indexOf(value.toLowerCase()) >= 0) {
viewModel.spots.push(iniList[x]);
}
}
}
};