此方法将对象合并到散列并返回该合并的结果。重复的键将导致覆盖。
语法
hash.merge(object);
返回值
返回生成的合并哈希。
例子
HTML
x
23
23
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 = $H({ name: 'Prototype', version: 1.6 });
9
h = h.merge({ version: 1.6, author: 'Sam' });
10
h.each(function(pair) {
11
alert(pair.key + ' = "' + pair.value + '"');
12
});
13
}
14
</script>
15
</head>
16
17
<body>
18
<p>Click the button to see the result.</p>
19
<br />
20
<br />
21
<input type = "button" value = "Result" onclick = "showResult();"/>
22
</body>
23
</html>
阅读剩余 34%
作者:terry,如若转载,请注明出处:https://www.web176.com/prototype_api/8728.html