This is a simple example to demonstrate how to put a PHP variable's value into a JS variable:
<?php
$secret = 'secretHashValue';
?>
<script>
let secret = '<?= $secret ?>';
console.log(secret);
</script>
Please note that this code needs to be in a .php file. You cannot use this within a JS file, because JS files will be delivered as static files and therefore will not be interpreted as PHP code by the webserver.
I've composed a small example using a form to POST something. Just create these two files and then open /form.php in your browser.
form.php
<html>
<head>
</head>
<body>
<form method="POST" action="/posted.php">
<input type="text" name="postedValue">
<button>Post this value</button>
</form>
</body>
</html>
posted.php
<html>
<head>
</head>
<body>
<?php
$postedValue = $_POST['postedValue'];
?>
<script>
let postedValue = '<?= $postedValue ?>';
alert('Posted value: ' + postedValue);
</script>
</body>
</html>
Hope this makes things a little clearer.
echo json_decode($oSecret->seeSecret());