Ko.observableArray () without adding elements

I tried KO but I am having problems getting the ObservableArray to work, the code is very simple

โ€‹var test = new ko.observableArray();
var regulararray = [];

test.push("item");
regulararray.push("regularpush");
console.log("the length for ko: " + test.length + " the length for regular array: " +    regulararray.length);โ€‹โ€‹

      

For some reason, the length of the knockout array is 0 and the length of the regular array is 1.

Why is this happening?

+3


source to share


1 answer


use test().length

insteadtest.length



+11


source







All Articles