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