SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Nov 23, 2006, 10:18 #1
- Join Date
- Oct 2002
- Posts
- 229
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
passing an array to another function
Hi,
Is it possible to pass an array to another functions?
I have my array:
HTML Code:var arraySub = newArray(); arraySub[0] = "Dave"; arraySub[1] = "Bob"; arraySub[2] = "Henry";
HTML Code:changeSub(2, Level,arraySub)
HTML Code:alert(arraySub[0]);
Eternity
-
Nov 23, 2006, 10:27 #2
- Join Date
- Apr 2006
- Posts
- 802
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
you are a little verbose in your array declaration.
var arraySub=['Tom','Dick',Harry');
changeSub(2,Level,arraySub);
The function you are calling has to handle arraySub:
function changeSub(a1,a2,a3){
alert(a3[2]);
}
-
Nov 23, 2006, 13:24 #3
- Join Date
- Oct 2002
- Posts
- 229
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
thats great - thanks.
My JavaScript isn't as good as it should be!Eternity
Bookmarks