Inaccurate children array length of node after destroying its any children

After destroying a child node, and then with a delay of 0.5 seconds ,checking the parent’s node children array length, it still returns the old value ie, doesn’t take in consideration the child node just destroyed .
Anyone have any idea what i am doing wrong?

How do you destroy children?
Please,Write your destroy child code.

for (var i = 0; i < this.onlineFriendsList.children.length; i++) {
this.onlineFriendsList.children[i].destroy();
}

I know there is destroyAllChildren method too, but essentially it is of same effect , so i can not see mistake in this.

and same line for deleting a single child
if(i==“someCondition”)
this.onlineFriendsList.children[i].destroy();

Also to add another issue , if for two times the destroying function gets called. and the browser tab is switched to another tab,
it doesnt destroy the node when i switch back. (Although the code gets executed for destroying the node.)>?

I think you must use parent.removeChild(child,true); to remove child.

You must query over children and find the correct child that must removed and then call parent.removeChild(child,true) .

destroy is better than removeChild as far as i know. It avoids memory leaks ,and beside destroy makes more sense, as it releases the memory