小弟在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)这是什么意思?
请前辈们说明的详细一点,谢谢
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)这是什么意思?
请前辈们说明的详细一点,谢谢
iterator || Prototype.K这么写,就哪个方法存在就返回哪个.
(iterator || Prototype.K)(value, index)然后执行该方法,value, index是参数.
!!是将返回值处理成true或false(保证返回值只能有这两种状态).如:返回的是个1,取反变成false,再取反变成true.