Yes, there is a third case where the scope chain is augmented (besides the let
mozilla-extension that Shog9 mentions), when a catch
block is evaluated:
The production Catch : catch
(Identifier ) Block is evaluated as
follows:
Let C be the parameter that has been passed to this production.
Create a new object as if by the expression new Object().
Create a property in the object Result(2). The property's name is
Identifier, valueisC. value, and
attributes are { DontDelete }.
Add Result(2) to the front of the scope chain.
Evaluate Block.
Remove Result(2) from the front of the scope chain.
Return Result(5).
So basically, a new object is created, with a property named like the Identifier passed to catch
, this new object is added to the scope chain, so we are able to use that identifier within the catch
block.
try {
throw "error";
} catch (identifier) {
// `identifier` accessible here..
}
But keep in mind that it only augments the current scope temporarily, to introduce the catch
Identifier, any variable declared inside will be simply hoisted to the top of it enclosing function.