so, in this post here people are discussing the fact that
A = [1,2,3];
and then doing
A = [];
will not reset the array but create a new one.
My question is, if I use a global object variable
myglobals = { A : [] }
Can I safely reset the array with
myglobals.A = [];
Right? Since that's referencing the same object property and thus I'm not actually creating a new array, am I?
Update to question due to remarks below
Since there is a general consensus that splice(0)
is the way to go, and since a very similar question has an answer that explains the impact to browser freeing up memory, I'm wondering if it's generally safe and proper to set any defined object (whether array or function or string, etc...) to null
in order to reset it's value while retaining it's reference?