Declare global constants in function javascript on DOMContentLoaded

Is there any way to declare constants when the DOMContentLoaded event triggers, that are accessible outside? window.addEventListener(‘DOMContentLoaded’, () => { const button = document….