"F. Da Costa" wrote:
Hi,
Could it be correct that the following code does *not* work because i'm not
using the var arr = new Array("a","b","c"); methodology??
Read through
http://devedge.netscape.com/library/...y.html#1194827
but there was no mention of particular constructors having to be used.
And if so how does one resolve it (if resolvable)?
TIA
Fermin DCG
==========================
var famname = new Array();
famname[0] = "Jan 0 Egil";
famname[1] = "To1ve";
famname[2] = "He2ge";
famname[3] = "Sta3le";
famname[4] = "Kai 4Jim";
famname[5] = "Bor5ge";
var famname2 = new Array(6);
famname2[0] = "Jan Egil2";
famname2[1] = "Tove2";
famname2[2] = "Hege2";
famname2[3] = "Stale2";
famname2[4] = "Kai Jim2";
famname2[5] = "Borge2";
famname = famname.concat(famname2); *Does not produce the concatenation!*
for (var i=0; i<6; i++) {
document.write(famname[i] + "<br />");
}
for (var i=0; i<6; i++) {
document.write(famname2[i] + "<br />");
}
Of COURSE it concatenates the arrays, but if you look at your "test code" you are simply looping
through 6 elements of the first array and 6 elements of the second array and outputting them.
If you modify your test code to actually output all of the array values, you'll see that famname
contains all the entries from both famname and famname2:
document.write("Contents of famname<br />");
for (var i=0; i<famname.length; i++) {
document.write(famname[i] + "<br />");
}
document.write("Contents of famname2<br />"):
for (var i=0; i<famname2; i++) {
document.write(famname2[i] + "<br />");
}
Better yet:
document.write("<p>Contents of famname<br />" + famname.join("<br />") + "</p>");
document.write("<p>Contents of famname2<br />" + famname2.join("<br />") + "</p>");
--
| Grant Wagner <gw*****@agricoreunited.com>
* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html
* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp
* Netscape 6/7 DOM Reference available at:
*
http://www.mozilla.org/docs/dom/domref/
* Tips for upgrading JavaScript for Netscape 7 / Mozilla
*
http://www.mozilla.org/docs/web-deve...upgrade_2.html