Re: Associative with MultiDimensional arrays
- From: Aziz <nomail@xxxxxxxxxxxx>
- Date: Tue, 12 Sep 2006 23:41:35 +0300
On 12 Sep 2006 09:38:57 -0700, "VK" <schools_ring@xxxxxxxxx> wrote:
Aziz wrote:
profiles["p1"][0] = new profileRecord(10, 20, 30);<snip>
profiles["p1"][1] = new profileRecord(10, 20, 30);
profiles["p1"][2] = new profileRecord(10, 20, 30);
alert(profiles["p1"][0].x);
is effectively
undefined[0] = new profileRecord(10, 20, 30);
alert(undefined[0].x)
this makes the problem more visual.
I expect "10" would be displayed but instead I get the error that
profiles.p1 doesn't exist. How can I correct it?
function showVal()
{
alert(profiles[1].x);
}
function profileRecord(x, y, z)
{
this.x = x;
this.y = y;
this.z = z;
}
var profiles = new Array(3);
profiles[0] = new profileRecord(10, 20, 30);
profiles[1] = new profileRecord(10, 20, 30);
profiles[2] = new profileRecord(10, 20, 30);
Thanks but what you suggest is a 2 dimensional array, while I try to
implement a 3 dimensional array with the first index as a string. Is
it not possible?
.
- Follow-Ups:
- References:
- Associative with MultiDimensional arrays
- From: Aziz
- Re: Associative with MultiDimensional arrays
- From: VK
- Associative with MultiDimensional arrays
- Prev by Date: Re: Javascript on steroids!
- Next by Date: Re: Inheritance breaks when setting prototype explicitly?
- Previous by thread: Re: Associative with MultiDimensional arrays
- Next by thread: Re: Associative with MultiDimensional arrays
- Index(es):
Relevant Pages
|