javascript access php variable

JavaScript
//passing PHP variable to JavaScript
var myJSVar = <?php echo json_encode($myPHPVar); ?>;
Source

Also in JavaScript: