473,231 Members | 1,746 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,231 software developers and data experts.

3d array in javascript

how i can set 3*3 array in javascript i have tried this but didnt work

<Script>
var a[2][2][2]=new array()
<\Script>
but it didnt work.
Bye & Best Of Luck.

Apr 18 '06 #1
10 29145

"hardik" <ha**********@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
how i can set 3*3 array in javascript i have tried this but didnt work

<Script>
var a[2][2][2]=new array()
<\Script>
but it didnt work.


var a = new Array();
a[0]= new Array();
a[0][5] = new Array;
a[0][5][72]="<h3>Hello matey</h3>";
document.writeln(a[0][5][72]);
Apr 18 '06 #2

"Hal Rosser" <hm******@bellsouth.net> wrote in message
news:Nz*******************@bignews5.bellsouth.net. ..

"hardik" <ha**********@gmail.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
how i can set 3*3 array in javascript i have tried this but didnt work

<Script>
var a[2][2][2]=new array()
<\Script>
but it didnt work.

var a = new Array();
a[0]= new Array();
a[0][5] = new Array;
a[0][5][72]="<h3>Hello matey</h3>";
document.writeln(a[0][5][72]);


You could loop through each array and declare new arrays for each element,
also
This is kinda clumsy - so I'm sure others will post a better solution.-
where I will take notes.
But the point is: its really an array of arrays [of arrays].... rather than
a single multidimensional array.

Apr 18 '06 #3
hardik said on 18/04/2006 2:34 PM AEST:
how i can set 3*3 array in javascript i have tried this but didnt work

<Script>
var a[2][2][2]=new array()
<\Script>


If you already had an array called 'a' with an array at index 2 and
another array at that array's index 2, then you could create an array at
index 2 of that last array.

But you haven't, so you have a script error. Also, the built-in array
object has a capital 'A' (to signify that you can use it as a
constructor perhaps).

To save on typing and potential typos, use an initialiser:

var a = [];
a[2] = [];
a[2][2] = [];
a[2][2][2] = [];
A one dimension array 1x3:

var a = ['A', 'B', 'C'];
A two dimension array 2x3:

var a = [
['A', 'B', 'C'],
['D', 'E', 'F']
];
A three dimension array 2x3x3:

var a = [
[
['a','b','c'],
['d','d','f'],
['g','h','i']
],
[
['j','k','l'],
['m','n','o'],
['p','q','r']
]
]

alert( a[0][1][2] ); // shows f
Keep going and it gets much harder to read...

--
Rob
Group FAQ: <URL:http://www.jibbering.com/FAQ>
Apr 18 '06 #4
VK

hardik wrote:
how i can set 3*3 array in javascript i have tried this but didnt work

<Script>
var a[2][2][2]=new array()
<\Script>


See the samples of 2D and 3D arrays emulation at
<http://www.geocities.com/schools_ring/ArrayAndHash.html>
:-)

Apr 18 '06 #5
thank u friends

Apr 18 '06 #6
RobG said the following on 4/18/2006 1:57 AM:

<snip>
A two dimension array 2x3:
var a = [
['A', 'B', 'C'],
['D', 'E', 'F']
];


I think that Rob knows, without reading further, what this post says but
a is not a "two dimension array" as it is a simple array that has arrays
as members. Javascript arrays are linear in fashion and as such you
can't have multi-dimensional arrays.

Sorry Rob, but I had to post for posterity sake :)

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 18 '06 #7
Randy Webb wrote:
RobG said the following on 4/18/2006 1:57 AM:

<snip>
A two dimension array 2x3:
var a = [
['A', 'B', 'C'],
['D', 'E', 'F']
];

I think that Rob knows, without reading further, what this post says but
a is not a "two dimension array" as it is a simple array that has arrays
as members. Javascript arrays are linear in fashion and as such you
can't have multi-dimensional arrays.

Sorry Rob, but I had to post for posterity sake :)


That's fine. Others may say that a is a 2D array (matrix) that is
constructed using 2 one-dimensional JavaScript Array objects. :-)
--
Rob
Apr 18 '06 #8
RobG said the following on 4/18/2006 9:31 AM:
Randy Webb wrote:
RobG said the following on 4/18/2006 1:57 AM:

<snip>
A two dimension array 2x3:
var a = [
['A', 'B', 'C'],
['D', 'E', 'F']
];

I think that Rob knows, without reading further, what this post says
but a is not a "two dimension array" as it is a simple array that has
arrays as members. Javascript arrays are linear in fashion and as such
you can't have multi-dimensional arrays.

Sorry Rob, but I had to post for posterity sake :)


That's fine. Others may say that a is a 2D array (matrix) that is
constructed using 2 one-dimensional JavaScript Array objects. :-)


Tis true, but VK might say that "RobG says JS has a multi-dimensional
array" <shudder> <g>

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Light humor is good for the soul every now and then.
Apr 18 '06 #9
VK

Randy Webb wrote:
Tis true, but VK might say that "RobG says JS has a multi-dimensional
array" <shudder> <g>


I believe in the JavaScript Array being Dynamic, Sparse, Jagged and
now, and ever and forever!

:-D

P.S. Please, it is just a joke, not a call for discussion.

Apr 18 '06 #10
VK said the following on 4/18/2006 1:37 PM:
Randy Webb wrote:
Tis true, but VK might say that "RobG says JS has a multi-dimensional
array" <shudder> <g>
I believe in the JavaScript Array being Dynamic, Sparse, Jagged and
now, and ever and forever!


<g>
:-D

P.S. Please, it is just a joke, not a call for discussion.


Surprisingly enough, I took it that way :)
--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 19 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: JesusFreak | last post by:
From: us_traveller@yahoo.com (JesusFreak) Newsgroups: microsoft.public.scripting.jscript Subject: toolbar script problem NNTP-Posting-Host: 192.92.126.136 Recently, I downloaded the following...
13
by: Kevin | last post by:
Help! Why are none of these valid? var arrayName = new Array(); arrayName = new Array('alpha_val', 1); arrayName = ; I'm creating/writing the array on the server side from Perl, but I
10
by: John Ortt | last post by:
Hi Everyone, I have created a Javascript menu for my site which uses frames. The first stage loads fine but I want two drill down menus ("About Me Menu" and "Projects Menu"). The pages load...
3
by: John Ortt | last post by:
I appologise for reposting this but I have been trying to find a solution all week with no avail and I was hoping a repost might help somebody more knowledgable than myself to spot the message... ...
9
by: mprocopio | last post by:
Fellow JavaScripters, I am looking for code or implementation ideas for converting an integer variable to a four-byte array. I'm porting some of my code from C#, where I make use of their...
8
by: J. B. Moreno | last post by:
What's the best (i.e. fastest) way to find out if an array contains a given value? Other than looping, the only way I know to do it is to use an associative array/hash instead.... Is there a...
2
by: BrianP | last post by:
Hi, I have had to invent a work-around to get past what looks like a JavaScript bug, the malfunctioning Perl-like JavaScript array functions including SPLICE() and UNSHIFT(). I have boiled it...
1
by: _andrea.l | last post by:
Salve a tutti, Ho un array di valori in un array javascript: lista=pippo lista=nando lista=.... Come inviare questa lista ad una pagina scritta in php? magari cliccando un bottone "invia...
104
by: Leszek | last post by:
Hi. Is it possible in javascript to operate on an array without knowing how mamy elements it has? What i want to do is sending an array to a script, and this script should add all values from...
7
by: sosamv | last post by:
Hi all!, I'm creating a app with PHP and MySQL, the system administrator is capable of creating profiles, on each profile we create, we add a custom access menu (a javascript tree view menu), theres...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.