It's very easy to do that.
In your JavaScript code, define a variable, and hard-code it to the variable in PHP:
<script language="javascript">
var my_name="<%=$my_name;%>";
</script>
and then in JavaScript, the variable my_name would equal $my_name in the script.