小弟在prototype类库中看到这样一段代码,不明白啥意思!!
function(iterator) {
    var result = true;
    this.each(function(value, index) {
      result = result && !!(iterator || Prototype.K)(value, index);
      if (!result) throw $break;
    });
    return result;
  }
不解:!!(iterator || Prototype.K)(value, index)这是什么意思?
请前辈们说明的详细一点,谢谢

解决方案 »

  1.   

    iterator 和 Prototype.K应该都是方法名,
    iterator || Prototype.K这么写,就哪个方法存在就返回哪个.
    (iterator || Prototype.K)(value, index)然后执行该方法,value, index是参数.
    !!是将返回值处理成true或false(保证返回值只能有这两种状态).如:返回的是个1,取反变成false,再取反变成true.
      

  2.   

    补充,!!function()是确保一个函数有返回值。。当函数中没有return 时。值应试是undefined 。  !! undefined == false;如果有兴趣发我短信,一起讨论prototype框架。。我也在学习使用中///