3

I'm trying out KO but have problems getting 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 while the regular array length is 1.

Why is this happening?

1 Answer 1

11

use test().length instead of test.length

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a million, i struggled with this for two hours without getting anywhere :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.