Tutorials Point


  Learn Prototype
  Prototype Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Prototype $H() Method


previous next AddThis Social Bookmark Button


Advertisements

The $H() function converts objects into enumerable Hash objects that resemble associative arrays.

The $H function is the shorter way to obtain a hash.

Syntax:

$H([obj])

Return Value:

  • A hash object.

Example:

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

This will display following result:

first=10&second=20&third=30

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements