At first it is good to clarify that "Concatenating PHP in JS" is perhaps not the best description of what happens there, I believe the correct term would be something like "Dynamically generating JS with PHP", what happens is that you creates parts of javascript by printing (echo) PHP content.
Answering the question: depending on your case I would say that it is the most appropriate option, yes. If you have a small JS, say something like your example of about 20 lines or less, and it needs to manipulate data that is server-side (php), give an echo and pick up the content you need from PHP is simply the way simpler, if it works and is readable code you do not have to complain.
If your JS has a reasonable size the situation already changes, having a mega block of javascript in the middle of PHP code is something that I consider dreadful, it completely disagrees with the code around, it is difficult to read and it is something that sharply breaks separation of responsibilities. In this case I recommend putting the JS in place, a separate .js file, and for you to have access to the phpnian values (heh that unfortunate word) you need there are three options:
Ajax, your javascript makes a request to the server asking for the values it needs. It is a "pure" solution since you do not mix php and javascript directly, however it is the most bloated since you will have to have an AJAX block in js, a php endpoint ("url that ajax will call") and a request extra that the client will have to do after loading the page.
In php echo the data that js needs as the value of an input hidden, eg echo '<input id="mypreciousdata" type="hidden" value="' . $var . '" />';
and in js you do something like console.log($("#mypreciousdata").val());
. This is also a "pure" solution in terms of code separation, does not generate overhead as ajax and is fairly simple.
In php generate a JS that has the data stored in some global object, ex: echo '<script>var MeuApp = {data1: "' . $var . '", data2: "' . $var2 . '"};</script>
and in your JS simply access that variable console.log(MeuApp.data1);
. This is usually my most used strategy because I consider pragmatic. Although it mixes js and php code to insert the data into the object will be just a few lines of code in it, being the bulk of your js that will use the data in a separate file.