返回到:Prototype – 枚举
此方法返回枚举的大小。
语法
Iterator.size();
返回值
返回枚举的大小。
例子
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
var arr = $R(1, 10).select(function(n) { return 0 == n % 2; });
alert("Test 1 : " + $R(1, 10).size() );
// Returns 10
alert("Test 2 : " + ['hello', 42, true].size() );
// Returns 3
alert("Test 3 : " + $H().size() );
// Returns 0
}
</script>
</head>
<body>
<p>Click the button to see the result.</p>
<br />
<br />
<input type = "button" value = "Result" onclick = "showResult();"/>
</body>
</html>返回到:Prototype – 枚举
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8576.html
支付宝
微信