This is the problem I see when browsing javascript.info, the expected result should be an "error", as in the website.
let phrase = 'Hello';
if(true) {
let user = "John";
function sayHi() {
console.log(phrase, user);
}
}
sayHi();
When I tried it, I found that both Chrome and Firefox output "Hello John" normally. But the error in Safari is "ReferenceError: Can't find variable: user"
I don't know how to describe this behavior, so I can't find relevant information in the search engine. I hope someone can answer my doubts. Thank you!
Browser version:
- Chrome 110
- Firefox 109
- Safari 16.3
This question seems to be different from here