Prototype - Enumerable any() 方法
此方法确定至少一个元素是否布尔值等同于 true,直接确定或通过提供的迭代器计算确定。
可选的 context 参数是迭代器函数将绑定到的内容。如果使用,迭代器内的 this 关键字将指向参数给出的对象。
语法
Iterator.any([context]);
返回值
如果迭代器中至少有一个值为 true,则返回布尔值 true。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
alert( "[].any() : " + [].any() );
// false(空数组没有元素)
alert("$R(0, 2).any() : " + $R(0, 2).any() );
// true(在第二个循环中,1 等于 true)
alert("[0, 1, 2].any() : " + [0, 1, 2].any() );
// true(1 和 2 个循环中为 true )
alert([9, 10, 15].any(function(n) { return n >= 10; }) );
// true(迭代器将返回 true 大于 10 )
}
</script>
</head>
<body>
<p>单击按钮查看结果。</p>
<br />
<br />
<input type = "button" value = "Result" onclick = "showResult();"/>
</body>
</html>

prototype_enumerating.html