原型 - keys() 方法



此方法返回該雜湊的所有鍵的陣列。

語法

hash.keys();

返回值

返回包含該雜湊的所有鍵的字串陣列。

示例

<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 });
            var arr = h.keys();
            
            arr.each(function(item) {
               alert(item );
            });
         }
      </script>
   </head>

   <body>
      <p>Click the button to see the result.</p>
      <br />
      <br />
      <input type = "button" value = "Result" onclick = "showResult();"/>
   </body>
</html>

輸出

prototype_hash_processing.htm
廣告