JavaScript Empty an Array

My favorite answer is:

while (A.length > 0) {

I strongly suggest to read the discussions of the Stack Overflow question [2]. The reason why I like the answer above is that long time ago, I had to remove all child nodes of a DOM element [3], the bug-free way to do this is:

while (elm.hasChildNodes()) {

Compare the idea of remove all child nodes and empty an array in above code, it is very clearly that the idea is the same. This is an interesting finding so I make it a post.


[2]How do I empty an array in JavaScript? - Stack Overflow
[3]JavaScript Remove All Children of a DOM Element