prototype - $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>

輸出

prototype_utility_methods.htm
廣告