I have one ViewModel that contains two arrays: arr1 and arr2. I would like arr2 to contains exactly what the arr1 contains. How can I do that?
var myViewModel = function() {
this.arr1 = ko.observableArray([]);
this.arr2 = ko.observableArray(this.arr1); //Doesn't work - I need to bind arr2 to changes in arr1
}
If you want to store reference to array’s elements use should unwrap observable:
If want clone array use
Slicefunction of array: