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


Groups > comp.lang.javascript > #10108

Re: Array syntax

Newsgroups comp.lang.javascript
Subject Re: Array syntax
From "Evertjan." <exjxw.hannivoort@interxnl.net>
References <8bcdc6d4-cf3b-4af3-901d-8464de4de2f2@k10g2000yqk.googlegroups.com> <4f0c025c$0$30150$a8266bb1@newsreader.readnews.com>
Message-ID <Xns9FD6A8EF2DCEBeejj99@194.109.133.133> (permalink)
Date 2012-01-10 15:36 +0000

Show all headers | View raw


Denis McMahon wrote on 10 jan 2012 in comp.lang.javascript:

> On Mon, 09 Jan 2012 14:11:11 -0800, DrKen wrote:
[..]
>> 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" };
>> loc["ie"] = { value: "IE", caption: "Inland Empire Regional Center" };
>> loc["in"] = { value: "IN", caption: "International" };
>> loc["la"] = { value: "LA", caption: "Los Angeles Regional Center" };
>> loc["mu"] = { value: "MU", caption: "Murrieta Regional Center" };
[...]
> 
> What I can tell you is that you're creating an array of objects, each 
> object having properties .value and .caption, such that, eg:
> 
> loc["ie"].caption = "Inland Empire Regional Center"
> loc["la"].value = "LA"

An array of objects would be populated thus:

loc[3] = { value: "AZ", caption: "Azusa" };
loc[7].caption = "Inland Empire Regional Center"

Despite de defining as an array, 
"loc" is NOT used as an ARRAY at al,
but as an OBJECT.

So why not define it as an object?

var loc = {};

-- 
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

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