It is possible to write php code in the JS file?

I am a beginner in JavaScript.
It is possible to write PHP code in the .js file

For example, I have a file one.js

var a = "<?= site_url('whole/new/world'); ?>";

If possible how to write the correct syntax?