Well, I don’t know if I understand it very well, but since Alert you would have the console.().
Instead of Alert('Hello world'), you would put console.log('Hello world'). In the case of Chrome, press F12 and open the console tab. So everything you send through the.log console will be shown in this tab silently, so the user won’t be able to see. Obs, this is for javascript codes.
In addition to the console.log, you have a console.warn that displays the text in dark yellow and with an exclamation signal, serves to draw attention. I also have the console.error that displays the message you want in the form of errors.
If you wanted to send a PHP variable to the.log console, you could use this code:
<?php
$array = array("um" => 1,"dois" => 2, 3, 4);
$debug = json_encode($array);
echo "<script>console.log($debug)</script>";
?>