此方法使用对象的键/值对更新散列。原始哈希将被修改。
重复键将导致哈希键被覆盖。如果它没有找到一个键,那么它将把它添加为一个新的键/值对。
语法
hash.update(object);
返回值
返回修改后的散列。
例子
HTML
x
21
21
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
var t = h.update({a: 'amrood', d:'drum'});
10
alert( "New Hash : " + t.inspect() );
11
}
12
</script>
13
</head>
14
15
<body>
16
<p>Click the button to see the result.</p>
17
<br />
18
<br />
19
<input type = "button" value = "Result" onclick = "showResult();"/>
20
</body>
21
</html>
阅读剩余 33%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8705.html