Why in this example i get Uncaught ReferenceError: CONST1 is not defined
consts.js
const CONST1 = "hello";
sample.js
jQuery.getScript("consts.js', function() {
alert(CONST1);
});
I guess it has something to do with scope. But since getScript uses global scope i cannot understand why this fails.
P.S. By using var instead of const it seems to work. But i cannot get the exact reason.