Does Prototype's Array.compact() filter recursively for multidimensional arrays?
I'm just wondering if Prototype's helper functions Array.compact() and Array.wit开发者_如何学运维hout() filter for multidimensional arrays. It doesn't look like it, and if so, was there a reason for this or is there another helper function in Prototype that does this?
From the source code itself:
function compact() {
return this.select(function(value) {
return value != null;
});
}
So I guess the answer is no. But wouldn't it be easy to implement your own helper function to do this? just run compact in a loop on the sub arrays.
精彩评论