Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Value of 'e' may be overwritten in IE 8 and earlier

I have code like this (that cancel ajax calls):

if (requests.length) {
    for (i=requests.length; i--;) {
        var r = requests[i];
        if (4 !== r.readyState) {
            try {
                r.abort();
            } catch(e) {
                self.error('error in aborting ajax');
            }
        }
    }
    requests = [];
    // only resume if there are ajax calls
    self.resume();
}

and jshint show error:

Value of 'e' may be overwritten in IE 8 and earlier.

in } catch(e) { what that error mean?

like image 615
jcubic Avatar asked Sep 08 '13 08:09

jcubic


2 Answers

The "Value of '{a}' may be overwritten in IE8 and earlier" error is thrown when JSHint or ESLint encounters a try...catch statement in which the catch identifier is the same as a variable or function identifer.
The error is only raised when the identifer in question is declared in the same scope as the catch.
In the following example we declare a variable, a, and then use a as the identifier in the catch block:

var a = 1;
try {
    b();
} catch (a) {}

To resolve this issue simply ensure your exception parameter has an identifier unique to its scope:

var a = 1;
try {
    b();
} catch (e) {}

http://linterrors.com/js/value-of-a-may-be-overwritten-in-ie8

like image 126
cuixiping Avatar answered Oct 18 '22 10:10

cuixiping


I found the error it's event handler that have e as event. And this should throw an error https://github.com/jshint/jshint/issues/618

like image 5
jcubic Avatar answered Oct 18 '22 10:10

jcubic