admin管理员组

文章数量:1277901

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?

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?

Share Improve this question asked Sep 8, 2013 at 8:16 jcubicjcubic 66.6k58 gold badges249 silver badges453 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 7

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./js/value-of-a-may-be-overwritten-in-ie8

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

本文标签: javascriptValue of 39e39 may be overwritten in IE 8 and earlierStack Overflow