You can create a php file instead (of your js file with all the code you already have in that js file + references to your php variables/functions) and include that in your main php file.
Example html:
js.php:
var a = = $example ?>;
alert(a);
will eventually output: