开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜