removeAll vs empty an array with [] in knockoutjs
knockout.js
Solution
From the end result point of view there is no difference between the two call, so you will end up with `myArray` containing no elements.
However there is one small difference (if you don't care about the different return values):
self.myArray([]);
will replace the underlying array instance with a newly created empty array.
While the
self.myArray.removeAll();
will remove all the items from the underlying array but it will keep the array instance.
So if you have multiple `ko.observableArray` using the same underlaying array you can see the difference between the two calls:
Demo JSFiddle.
Problem
I want to throw away the data in my observablearray everytime I get data from my server. What is the difference in functionality between ``` self.myArray([]); ``` vs ``` self.myArray.removeAll(); ```