How do I overwrite (or unset and then set) an array? Seems like "array = new_array"
doesn't work.
To create an empty array to assign to the variable, you can use the Array constructor:
array = new Array();
Or you can use an empty array literal:
array = [];
If you have several references to one array so that you have to empty the actual array object rather than replacing the reference to it, you can do like this:
array.splice(0, array.length);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With