返回到:Prototype – 枚举
此方法根据 == 比较运算符确定给定对象是否在 Enumerable 中。这是 member() 方法的别名。
如果您需要检查是否有元素匹配给定的谓词,请改用 any() 方法。
语法
Iterator.include(object);
返回值
如果找到给定的对象,则返回 true,否则返回 false。
例子
HTML
x
23
23
1
<html>
2
<head>
3
<title>Prototype examples</title>
4
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
5
6
<script>
7
function showResult() {
8
alert("$R(1,15).include(10) : " + $R(1,15).include(10) );
9
// Returns true
10
11
alert("['hello', 'world'] : " + $R(1,15).include('HELLO') );
12
// Returns false
13
}
14
</script>
15
</head>
16
17
<body>
18
<p>Click the button to see the result.</p>
19
<br />
20
<br />
21
<input type = "button" value = "Result" onclick = "showResult();"/>
22
</body>
23
</html>
返回到:Prototype – 枚举
阅读剩余 76%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8610.html