Prototype using hash objects

Source: Internet
Author: User

1. Preface

The hash object is roughly the following method:

1) Clone (): Copies the existing hash object and returns the new hash object generated by the copy.

2) each (iterator): Iterates through the iterator of each Key-value object in the hash object, where iterator is a function of the shape functions (pair) {}, where pair is the Key-value object of the hash object.

3) Get (Key): Returns value based on key, basically similar to the Get () method of Java map.

4) Inspect (): Returns a string that shows the key-value pair of the hash object, similar to the ToString () method of Java map.

5) keys (): Returns an array of all key elements of the hash object.

6) VALUES (): Returns an array of all value of the hash object. 、

7) Merge (Otherhash): Merges the new hash object into the original hash object and returns the new hash object.

8) Set (key, value): Sets a pair of key-value pairs, similar to the put () method of Java map.

9) Toobject (): Converts a hash object into a JavaScript object, in fact the hash object and JavaScript are key-value pairs, so it is very convenient to convert each other.

Toquerystring (): Converts a hash object into a query string, which appears as a ' key1= value1&key2=value2 ' form.

One) unset (key): Removes the key-value pair corresponding to key, and returns the value corresponding to key after executing the method.

Update (object): Updates the current hash object with object.

2. Example
<! DOCTYPE Html>3. Running Results

Prototype using hash objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.