Yup. Don't put constants at the top level.
Best to wrap you entire code in a function so everything is scoped within the function...
<script type="text/javascript">
(function() {
const DEFAULT_WIDTH = 160
RED.nodes.registerType('image viewer', {
...
}
})();
</script>