返回到:Prototype – 枚举
此方法返回枚举的大小。
语法
Iterator.size();
返回值
返回枚举的大小。
例子
HTML
x
28
28
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
var arr = $R(1, 10).select(function(n) { return 0 == n % 2; });
9
10
alert("Test 1 : " + $R(1, 10).size() );
11
// Returns 10
12
13
alert("Test 2 : " + ['hello', 42, true].size() );
14
// Returns 3
15
16
alert("Test 3 : " + $H().size() );
17
// Returns 0
18
}
19
</script>
20
</head>
21
22
<body>
23
<p>Click the button to see the result.</p>
24
<br />
25
<br />
26
<input type = "button" value = "Result" onclick = "showResult();"/>
27
</body>
28
</html>
返回到:Prototype – 枚举
阅读剩余 80%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8576.html