Prototype-dollarh-method

提供:Dev Guides
移動先:案内検索

プロトタイプ-$ H()メソッド

$ H()関数は、オブジェクトを連想配列に似た列挙可能なハッシュオブジェクトに変換します。

$ H関数は、ハッシュを取得するためのより短い方法です。

構文

$H([obj])

戻り値

ハッシュオブジェクト。

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>

      <script>
         function ShowHash() {
           //let's create the object
            var a = {first: 10, second: 20, third: 30};

           //now transform it into a hash
            var h = $H(a);
            alert( h.toQueryString());
         }
      </script>
   </head>

   <body>
      <p>Click "Show Value" button to see the result</p>

      <form>
         <input type = "button" value = "Show Value" onclick = "ShowHash();"/>
      </form>

   </body>
</html>

出力