In the past I have used
var App = App || {};
to assign or instantiate a common App object in various js scripts loaded separately into the browser.
However, using let
and const
instead of var
throws a reference error:
const App = App || {}; // or let App = App || {};
Uncaught ReferenceError: App is not defined
at <anonymous>:1:11
What's going on here? If I want to continue using this pattern, do I have to stick to var
?