In PHP I can write a function like this:
function myFunction(myArray)
{
foreach(myArray)
{
// do stuff with array
}
}
Then I can call it like this (maybe ugly, but still works):
myFunction(array("string1","string2"));
I want to do something similar with JavaScript but can't figure out if it's possible to pass arrays to functions like that. This is my psuedo-function:
function myFunction(myArray)
{
for (index = 0; index < myArray.length; ++index)
{
// do stuff with array
}
}
I want to call it from a button using onClick like this:
<input type="button" value="myButton" onClick="return myFunction(array("string1","string2"))">
Can this be accomplished in a simle way?