Prototype - get() 方法
此方法用于获取哈希键的属性值。
语法
hash.get(key);
返回值
返回与已暂停键对应的值。
示例
<html> <head> <title>Prototype examples</title> <script type = "text/javascript" src = "/javascript/prototype.js"></script> <script> function showResult() { var h = new Hash({ a: 'apple', b: 'banana', c: 'coconut' }); alert("Value of a : " + h.get('a') ); // -> 'apple' alert("Value of b : " + h.get('b') ); // -> 'banana' alert("Value of d : " + h.get('d') ); // -> undefined } </script> </head> <body> <p>单击按钮查看结果。</p> <br /> <br /> <input type = "button" value = "Result" onclick = "showResult();"/> </body> </html>
输出
prototype_hash_processing.html