Pass a global variable to javascript method

Hello,
how can I pass a global variable to javascript method? This is my javascript method.

let request = new XMLHttpRequest();
request.open('GET', 'https://api.telegram.org/bot'+ [telegram_token] +'/sendMessage?chat_id=123456789&text=Test%20test%20post,%20task%20created');
request.send();

Hi, just echo the value creating a js variable.

?>
<script type="text/javascript">
const telegram_token = "<?php echo [telegram_token]; ?>";
</script>
<?php

thanks it works great