Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #10096

Re: Array syntax

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail
From "Jukka K. Korpela" <jkorpela@cs.tut.fi>
Newsgroups comp.lang.javascript
Subject Re: Array syntax
Date Tue, 10 Jan 2012 00:58:22 +0200
Organization A noiseless patient Spider
Lines 43
Message-ID <jefred$19r$1@dont-email.me> (permalink)
References <8bcdc6d4-cf3b-4af3-901d-8464de4de2f2@k10g2000yqk.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 9 Jan 2012 22:58:21 +0000 (UTC)
Injection-Info mx04.eternal-september.org; posting-host="ngroV0xYIIv0dzjhyZhv5A"; logging-data="1339"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/hh/YezAYwtbuidntaPUSo"
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <8bcdc6d4-cf3b-4af3-901d-8464de4de2f2@k10g2000yqk.googlegroups.com>
X-Antivirus-Status Clean
X-Antivirus avast! (VPS 120109-1, 09.01.2012), Outbound message
Cancel-Lock sha1:Fqo3R//lVqatY5zBjRiA4uQlryc=
Xref x330-a1.tempe.blueboxinc.net comp.lang.javascript:10096

Show key headers only | View raw


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


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