Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #10096
| From | "Jukka K. Korpela" <jkorpela@cs.tut.fi> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: Array syntax |
| Date | 2012-01-10 00:58 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <jefred$19r$1@dont-email.me> (permalink) |
| References | <8bcdc6d4-cf3b-4af3-901d-8464de4de2f2@k10g2000yqk.googlegroups.com> |
2012-01-10 0:11, DrKen wrote:
> I'm trying to understand some JavaScript that I have to maintain and
> in looking at one bit [...] I'm wondering in fact if it is from a
> JavaScript library of some kind. I am not incliuding the whole array
> but this should be sufficient:
The whole array is needed, but what matters is how it is used. Often a
URL tells more than 10,000 words.
> var locations = $("#field-location select:first option");
This appears to use the widely used jQuery library, though one cannot be
absolutely sure without seeing the context. After all, "$" is in
principle just yet another identifier. The rest of the code snippet does
not seem to have any direct relationship to jQuery.
> var loc = new Array();
> loc["az"] = { value: "AZ", caption: "Azusa" };
> loc["co"] = { value: "CO", caption: "Colorado Springs" };
> loc["hd"] = { value: "VI", caption: "High Desert Regional Center" };
It's difficult to guess what the idea might be. This looks like an
unnecessarily complicated way of mapping two-letter codes to names, and
the initialization with new Array() does not appear to be useful. After
all, loc is not an array but an object, though informally objects might
be described as kind-of associative arrays.
> The array values are used later in the .js file so that when a user
> clicks on one select and makes a choice, another box shows one or more
> of these locations that are specific to it. That has always worked
> fine. What I want to know, to be very specific is, if a user selects
> the choice "High Desert" (hd), the result will be that the select will
> return "VI" as the value that should go back to ther server?
Well this entirely depends on what happens in the code. It's not even
certain what strings appear in the user interface, visible to the user,
though I would expect the caption values to be used. But what happens
upon selection is up to the code - it could result in "VI" being sent,
or "hd" being sent, or (in principle) something else.
--
Yucca, http://www.cs.tut.fi/~jkorpela/
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Array syntax DrKen <javajedi2@yahoo.com> - 2012-01-09 14:11 -0800
Re: Array syntax "Jukka K. Korpela" <jkorpela@cs.tut.fi> - 2012-01-10 00:58 +0200
Re: Array syntax Denis McMahon <denismfmcmahon@gmail.com> - 2012-01-10 09:18 +0000
Re: Array syntax "Evertjan." <exjxw.hannivoort@interxnl.net> - 2012-01-10 15:36 +0000
Re: Array syntax Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-01-12 00:26 +0100
csiph-web