Here’s an example:
OUTPUT: Jane
The limitation in the above method is that you can use only string or integers as keys. When you are using integers as keys, it gets converted to string while setting the property. If you want to use objects as keys, check this nice library called jshashtable
You can also write the code shown above in the following way:
Tweet
No comments:
Post a Comment