开发者

Does Prototype's Array.compact() filter recursively for multidimensional arrays?

开发者 https://www.devze.com 2022-12-17 20:43 出处:网络
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 fo

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

精彩评论

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