<script> function foo() { window.yourGlobalVariable = ...; } </script>
window.my_function = function(){ // }
globalThis.yourGlobalVariable = ...;