Possible Duplicate:
how to empty an array in JavaScript
var jsonParent = [];
This is my jsonArray I am pushing some elements in the array, but now I want to empty this array and remove all elements from it.
This is my jsonArray I am pushing some elements in the array, but now I want to empty this array and remove all elements from it. |
|||
marked as duplicate by Christoph, Niranjan Kala, Barmar, martin clayton, Vikdor Oct 5 '12 at 1:14This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question. |
|||
|
In terms of saving memory and references use
|
|||||||||
|
just assign
again when you want to remove all elements |
|||
|
If there are no other references to the same array then the easiest thing to do is just assign
But if your code has other references to the same array instance then that would leave those other references with the original (populated) array and
(Note also that you are not using JSON here in any way. It's not JSON if it's not a string.) |
|||
|