Reputation: 14318
I was trying to implement the following code:
var action = function (e) {
if (!e) {
var e = window.event;
}
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
container.objet.hide();
}
But jslint complains about the following:
'e' is already defined. var e = window.event;
What is the best way to fix this problem?
Upvotes: 2
Views: 1173
Reputation: 11
In the function, actually e has been defined as argument. so when you define some variable same as arguments, it will complains.
Upvotes: 0
Reputation: 943142
Using a named argument creates a locally scoped variable (which is what var
does). Since you have an argument e
and you use var e
you are trying to create the variable twice.
Remove the var
from where you use e
the third time time.
var event = function (e) { // First time
if (!e) { // Second time
e = window.event; // Third time
Upvotes: 5