vkidv
05-07-2006, 12:05 PM
Hello,
I'm looking for a way to pass an array as a function's arguments.
Does anybody have any ideas to do this?
I do not want to do:
DoThat(myarray[0],myarray[1],myarray[2]) ;
I have tried
DoThat(myarray)
It sees the entire contents of myarray as the first argument of the function, not desirable.
I want the array(which is in order) to equal the functions arguments:
Eg:
myarray = ["param1","param2","param3"]
function DoThat(argument1, argument2, argument3) {
alert( argument1 + argument2 + argument3) ;
}
DoThat(myarray)
should make:
param1param2param3
Use the contents of the array as all the arguments of the function.
Can anybody make any suggestions?
I know the argument is an object and not an array.. If it is how I think it works, perhaps It would be possible to write a function that structures an array as a new object with the property contents as the array data and the property names as the actual argument names of the function?
I'm looking for a way to pass an array as a function's arguments.
Does anybody have any ideas to do this?
I do not want to do:
DoThat(myarray[0],myarray[1],myarray[2]) ;
I have tried
DoThat(myarray)
It sees the entire contents of myarray as the first argument of the function, not desirable.
I want the array(which is in order) to equal the functions arguments:
Eg:
myarray = ["param1","param2","param3"]
function DoThat(argument1, argument2, argument3) {
alert( argument1 + argument2 + argument3) ;
}
DoThat(myarray)
should make:
param1param2param3
Use the contents of the array as all the arguments of the function.
Can anybody make any suggestions?
I know the argument is an object and not an array.. If it is how I think it works, perhaps It would be possible to write a function that structures an array as a new object with the property contents as the array data and the property names as the actual argument names of the function?