From javascript to php through form method="post".
From php to javascript as function parameters. But do note that they are represented as strings and as such will only work for variables containing characters, strings, numbers. Arrays need to be dealt with in some way. For example, var_export the array, remove line breaks (don't remember if it's ascii 0xa or 0xd in there) and you might have to escape quotes as well then pass this on to the script as a function parameter and parse the string.