此方法将散列键的属性设置为值并返回值。
语法
hash.set(key, value);
返回值
返回哈希值。
例子
HTML
x
26
26
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 h = new Hash({ a: 'apple', b: 'banana', c: 'coconut' });
9
alert( "h.inspect() : " + h.inspect() );
10
11
h.set('d', 'orange');
12
alert( "h.inspect() : " + h.inspect() );
13
14
h.set('a', 'kiwi');
15
alert( "h.inspect() : " + h.inspect() );
16
}
17
</script>
18
</head>
19
20
<body>
21
<p>Click the button to see the result.</p>
22
<br />
23
<br />
24
<input type = "button" value = "Result" onclick = "showResult();"/>
25
</body>
26
</html>
阅读剩余 39%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8722.html