On the MDN page for the wheel
event, there is a code sample which includes the following at lines 30-31:
function( originalEvent ) {
!originalEvent && ( originalEvent = window.event );
The second line seems to take a number of shortcuts that rely on the way JavaScript evaluates boolean expressions internally. If I understand correctly, its purpose is to set originalEvent
to window.event
if no argument is passed. Its action is the same as the following:
if (!originalEvent) {
originalEvent = window.event;
}
or
orginalEvent = (originalEvent) ? orginalEvent : window.event;
What advantages are there in using the construction from the MDN site?