Titanium: Remove All Children of View

I picked up this function somewhere a while ago, it’s useful when you want to remove all the children elements of a view in Titanium.

function removeAllChildren(obj) {
    var c = obj.children.slice(0);
    for (var i = 0; i < c.length; ++i) {
        obj.remove(c[i]);
    }
}