原型 - 枚举 include() 方法
此方法确定给定对象是否在枚举中,基于 == 比较运算符。这是 member() 方法的别名。
如果您需要检查是否存在与给定谓词匹配的元素,请改用 any() 方法。
语法
Iterator.include(object);
返回值
如果找到给定对象则返回真,否则返回假。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
alert("$R(1,15).include(10) : " + $R(1,15).include(10) );
// Returns true
alert("['hello', 'world'] : " + $R(1,15).include('HELLO') );
// Returns false
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<br />
<br />
<input type = "button" value = "Result" onclick = "showResult();"/>
</body>
</html>
输出
prototype_enumerating.htm
广告