Link to home
Start Free TrialLog in
Avatar of chsalvia
chsalvia

asked on

Window.event

Can someone give me an explanation of the following line:

Assuming a function like:

function mouseUp(ev)

What does this line mean:

ev = ev || window.event;

A lot of code snippets I see have an event variable as an argument to some event-based function, like mouseUp, mouseMove, or whatever.  But the event variable is never actually passed to the function - it's simply stated as an argument to the function, so essentially that means it would be undefined.

So, what does ev = ev || window.event mean?  It seems like this line tries to set ev to its own value, which is undefined, or to the value of window.event.  What does this line achieve?
ASKER CERTIFIED SOLUTION
Avatar of smaccari
smaccari

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial