You said: If I do a
alert(ContArray.length);
I get two.
Or did you mean: I get six ???
Because it was confusing to me so I made this example.
So this was the right time for my first attempt to make multi-dimensional array. This is what I found out(my reference is quit sparing with information about it)
Please xutopia or other experts, correct me if I'm wrong :
var ContArray = new Array();
ContArray[0] = new Array();
ContArray[1] = new Array();
ContArray[2] = new Array();
ContArray[3] = new Array();
ContArray[4] = new Array();
ContArray[5] = new Array();
var show = 'column1\tcolumn2\n'
show = show + ContArray[0][0] + '\t' + ContArray[0][1] + '\n'
show = show + ContArray[1][0] + '\t' + ContArray[1][1] + '\n'
show = show + ContArray[2][0] + '\t' + ContArray[2][1] + '\n'
show = show + ContArray[3][0] + '\t' + ContArray[3][1] + '\n'
show = show + ContArray[4][0] + '\t' + ContArray[4][1] + '\n'
show = show + ContArray[5][0] + '\t' + ContArray[5][1] + '\n'
show = show + '\n'
show = show + 'column length = ' + ContArray.length + '\n'
show = show + '\n'
show = show + 'row length = ' + ContArray[0].length + '\n'
alert(show);
BTW: \t is the escape sequence for "horizontal tab"
Erik
<!-- My sport: Boomerang throwing !!
This year I will participate at the World Championships in Germany. (
Boomerang, I automaticaly assumed if he was getting two using ContArray.lenght he should get six using ContArray[0].length. You are right however. It is the other way around.
How do you like this shorthand way of doing the same thing?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.