Prototype - unset() 方法
此方法删除哈希键的属性并返回其值。如果在哈希中找不到该键,则不执行任何操作并返回未定义。
语法
hash.unset(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' }); // Returns 'apple' alert( "h.unset('a') : " + h.unset('a') ); } </script> </head> <body> <p>单击按钮查看结果。</p> <br /> <br /> <input type = "button" value = "Result" onclick = "showResult();"/> </body> </html>
输出
prototype_hash_processing.html