I\'m trying to understand why I\'m getting the following error, not how to work around it.
Passing the following code to JSLint or JSHint yields the er
The specification is quite clear that any name defined a catch statement will do nothing more than shadow a surrounding name. Beyond that I would not consider these errors as nothing more than a warning. Just using pure intuition I believe that this is simply overzealous analysis on the part of the designer of those Lint tools.
Since a catch block introduces a new scope, using the same name will simply shadow any similar names in the enclosing scope. This isn't necessarily a bad thing if you are aware of the semantics. If you are coding under the assumption that the enclosing err
will be accessible than you'll need to change your assumptions.
Specification
The production Catch : catch ( Identifier ) Block is evaluated as follows:
NOTE No matter how control leaves the Block the LexicalEnvironment is always restored to its former state.