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, 4062👍, 0💬
Popular Posts:
How To Use Subqueries in the FROM clause? - MySQL FAQs - SQL SELECT Statements with JOIN and Subquer...
What Articles Have You Read about JUnit? There are a number of JUnit articles that you should read: ...
What is the output of printf("%d")? 1. When we write printf("%d",x); this means compiler will print ...
What will be printed as the result of the operation below: main() { char *ptr = " Cisco Systems"; *p...
.NET INTERVIEW QUESTIONS - What are Daemon threads and how can a thread be created as Daemon? Daemon...