How to use php function inside javascript file?

How to use php function inside javascript file?

Hello i have this function for languages using php

function lang($var){
return $var;
}

when i write 
<?php echo lang("test lang"); ?> the function output will return ( test lang )

so now is my question how can i use this function inside javascript without creating another languages function to use it inside javascript, all i need is i want to convert or another idea to use php function inside js files.



Kind regards.