Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How to use strings as array indexes using JavaScript?
How to use strings as array indexes using JavaScript?
✍: Guest
Javascript does not have a true hashtable object, but through its wierdness, you can use the array as a hashtable.
<script type="text/javascript">
var days = ["Sunday","Monday","Tuesday","Wednesday",
"Thursday","Friday","Saturday"];
for(var i=0; i < days.length; i++) {
days[days[i]] = days[i];
}
document.write("days[\"Monday\"]:"+days["Monday"]);
</script>
This produces
days["Monday"]:Monday
2011-07-19, 4143👍, 0💬
Popular Posts:
What does AddressOf operator do in background ? The AddressOf operator creates a delegate object to ...
How To Build WHERE Criteria with Web Form Search Fields? - MySQL FAQs - Managing Tables and Running ...
What is difference between ADPATCH and OPATCH ? # ADPATCH is utility to apply ORACLE application Pat...
How do we host a WCF service in IIS? Note: - The best to know how to host a WCF in IIS is by doing a...
How To Create an Add-to-My-Yahoo Button on Your Website? - RSS FAQs - Adding Your Feeds to RSS News ...