Safari doesn’t find const within function (Can’t find variable)

JavaScript in Safari fails and execution is stopped if const is used within function. All other browsers (Chrome, Firefox, …) work correctly, even on macOS.

My code (simplified):

    const a = 1;
    function f() {
      console.log(a);
    }
    f();

In JavaScript console I can see:
[Error] ReferenceError: Can't find variable: a

I resolved it by changing const to var and it started to work immediately. (I didn’t try let).

    var a = 1;
    function f() {
      console.log(a);
    }
    f();

I tried to investigate and understand why this is a problem. However, none of the resources gave me an answer why const should not work within function:

Is it something to do with Safari (security?) settings?

Unfortunately, I can’t troubleshoot this further as I’m working on Windows and don’t have macOS available all the time.