You can use a code like the following:
<?php
$name= "Hello World";
?>
<script type="text/javascript">
var x = "<?php echo "$name"?>";
document.write(x);
</script>
and then insert this code in a php page: but not with a js
extension, but with some like inc