Prototype - merge() 方法
此方法将对象合并到哈希并返回合并的结果。重复的键将导致覆盖。
语法
hash.merge(object);
返回值
返回合并后的哈希。
示例
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function showResult() { var h = $H({ name: 'Prototype', version: 1.6 }); h = h.merge({ version: 1.6, author: 'Sam' }); h.each(function(pair) { alert(pair.key + ' = "' + pair.value + '"'); }); } </script> </head> <body> <p>单击按钮查看结果。</p> <br /> <br /> <input type = "button" value = "Result" onclick = "showResult();"/> </body> </html>
输出
prototype_hash_processing.html