I was investigating one problem where content of web page is not getting loaded in Safari, on further investigation it was found that it is because of variable scope (const vs var).
if (1 == 1) {
const a = 1;
function f() {
console.log(a);
}
f();
}
Error:
Can't find variable: a
With variable type as const was getting error in Safari browser and all browser in Iphone, And it was working in all other browser except Safari on desktop.
After changing it to var
it has solved the issue. But still not able to find the justification why with const it was not working in Safari.
What is correct behaviour for const?