返回到:Prototype – 数组处理
此方法清除数组(使其为空)。
语法
array.clear();
返回值
返回一个空数组。
例子
HTML
x
30
30
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 guys = ['Sam', 'Justin', 'Andrew', 'Dan'];
9
alert("Before using clear" );
10
11
guys.each(function(item) {
12
alert(item );
13
});
14
guys.clear();
15
alert("After using clear" );
16
17
guys.each(function(item) {
18
alert(item );
19
});
20
}
21
</script>
22
</head>
23
24
<body>
25
<p>Click the button to see the result.</p>
26
<br />
27
<br />
28
<input type = "button" value = "Result" onclick = "showResult();"/>
29
</body>
30
</html>
返回到:Prototype – 数组处理
阅读剩余 81%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8800.html