Why does redeclaring a function identifier within a try block throw a SyntaxError?

Viewed 1236

The following lines of JavaScript

try {
    function _free() {}
    var _free = 1;
} finally { }

result in the following error:

 Uncaught SyntaxError: Identifier '_free' has already been declared

However, the following two blocks of JavaScript code don't:

  1. Without the try block scope:

    function _free() {}
    var _free = 1;
    
  2. Within a function scope:

    function a() {
        function _free() {}
        var _free = 1;
    }
    

But why?

(Testing environment: Chromium 61.0.3126.0)

2 Answers
Related